Part Number Hot Search : 
EVKIT RS205 ML4732 0103NA 000MHZ 6A40G UPD3594 UDN2993B
Product Description
Full Text Search
 

To Download HT82A520R11 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ht82a520r/ht82a620r full speed usb 8-bit otp mcu with spi selection table part no. data memory program memory i/o timer a/d pwm spi package ht82a520r 160 8 4k15 24 16-bit1 ? 12-bit3 1 20/24/28ssop, 32qfn ht82a620r 160 8 4k15 24 16-bit 1 12-bit 16 12-bit3 1 20/24/28ssop, 32qfn rev.1.30 1 january 14, 2011 general description the ht82a520r/ht82a620r are 8-bit high perfor- mance risc-like microcontrollers designed for usb keyboard mouse and joystick product applications. the advantages of low power consumption, i/o flexibil - ity, programmable frequency divider, timer functions, oscillator options, multi-channel a/d converter, pulse width modulation function, watchdog timer, spi inter- faces, power down and wake-up functions, enhance the versatility of these devices to suit a wide range of ap- plication possibilities such as sensor signal processing, motor driving, industrial control, consumer products, subsystem controllers, etc. features operating voltage: f sys = 6mhz: 2.2v~5.5v f sys = 12mhz: 4.0v~5.5v 4k15 program memory 1608 data memory ram usb 2.0 full speed compatible single external interrupt input shared with i/o line single 16-bit programmable timer/event counters with overflow interrupt single spi interfaces (master and slave mode) shared with pa0~pa3 total of 4 interrupts - int , timer, spi, usb watchdog timer function power down and wake-up functions to reduce power consumption 16 channel 12-bit resolution a/d converter for ht82a620r 3-channel 12-bit pwm output shared with three i/o lines 24 bidirectional i/o lines up to 0.33ms instruction cycle with 12mhz system clock at v dd =5v max. 4 endpoints supported - endpoint 0 included all endpoints support interrupt and bulk transfer endpoint 0 supports control and interrupt all endpoints except endpoint 0 can be configured as 8, 16, 32, 64 fifo size endpoint 0 has 8 byte fifo total fifo size: 64+8 bytes (ram0: 48 bytes; ram1:16 bytes, 8 bytes for endpoint0) 6-level subroutine nesting bit manipulation instruction table read instructions 63 powerful instructions all instructions executed in one or two instruction cycles low voltage reset function (2.0v0.1%) 20/24/28-pin ssop, 32-pin qfn package pb7 can configure as gpio or vddio by option. the power supply of the pin pb0~pb6 can be optioned as vdd or vddio
block diagram ht82a520r ht82a620r ht82a520r/ht82a620r rev.1.30 2 january 14, 2011 s t a c k d a t a m e m o r y i / o p o r t s w a t c h d o g t i m e r o t p p r o g r a m m e m o r y 8 - b i t r i s c m c u c o r e w a t c h d o g t i m e r o s c i l l a t o r r e s e t c i r c u i t i n t e r r u p t c o n t r o l l e r c r y s t a l o s c i l l a t o r l o w v o l t a g e r e s e t p w m g e n e r a t o r s p i i n t e r f a c e u s b 2 . 0 f u l l s p e e d e n g l i n e u s b 2 . 0 x c v r 3 . 3 v r e g u l a t o r 1 6 - b i t t i m e r s t a c k d a t a m e m o r y i / o p o r t s w a t c h d o g t i m e r o t p p r o g r a m m e m o r y 8 - b i t r i s c m c u c o r e w a t c h d o g t i m e r o s c i l l a t o r r e s e t c i r c u i t i n t e r r u p t c o n t r o l l e r c r y s t a l o s c i l l a t o r l o w v o l t a g e r e s e t a / d c o n v e r t e r p w m g e n e r a t o r s p i i n t e r f a c e u s b 2 . 0 f u l l s p e e d e n g l i n e u s b 2 . 0 x c v r 3 . 3 v r e g u l a t o r 1 6 - b i t t i m e r
pin assignment ht82a520r/ht82a620r rev.1.30 3 january 14, 2011 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 2 3 4 5 6 7 8 9 1 0 p b 6 p b 7 v d d d - / d a t a d + / c l k v 3 3 o o s c o o s c i v s s r e s p b 1 p b 0 / p w m 2 p a 7 / t m r p a 6 / i n t p a 5 / p w m 1 p a 4 / p w m 0 p a 3 / s d o p a 2 / s d i p a 1 / s c k p a 0 / s c s h t 8 2 a 5 2 0 r 2 0 s s o p - a 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 p b 2 p b 1 p b 0 / p w m 2 p a 7 / t m r p a 6 / i n t p a 5 / p w m 1 p a 4 / p w m 0 p a 3 / s d o p a 2 / s d i p a 1 / s c k p a 0 / s c s p c 7 p b 5 p b 6 p b 7 v d d d - / d a t a d + / c l k v 3 3 o o s c o o s c i v s s r e s p c 0 p b 4 p b 5 p b 6 p b 7 v d d d - / d a t a d + / c l k v 3 3 o o s c o o s c i v s s r e s p c 0 p c 1 p b 3 p b 2 p b 1 p b 0 / p w m 2 p a 7 / t m r p a 6 / i n t p a 5 / p w m 1 p a 4 / p w m 0 p a 3 / s d o p a 2 / s d i p a 1 / s c k p a 0 / s c s p c 7 p c 6 h t 8 2 a 5 2 0 r 2 4 s s o p - a h t 8 2 a 5 2 0 r 2 8 s s o p - a h t 8 2 a 5 2 0 r 3 2 q f n - a 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 2 2 2 3 2 4 2 52 62 72 82 93 03 13 2 p a 1 / s c k p a 2 / s d i p a 3 / s d o p a 4 / p w m 0 p a 5 / p w m 1 p a 6 / i n t p a 7 / t m r p b 0 / p w m 2 p c 0 r e s v s s o s c i o s c o v 3 3 o d + / c l k d - / d a t a v d d p b 7 p b 6 p b 5 p b 4 p b 3 p b 2 p b 1 p c 1 p c 2 p c 3 p c 4 p c 5 p c 6 p c 7 p a 0 / \ s c s 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 2 3 4 5 6 7 8 9 1 0 p b 6 / a n 6 p b 7 / a n 7 v d d d - / d a t a d + / c l k v 3 3 o o s c o o s c i v s s r e s p b 1 / a n 1 p b 0 / a n 0 / p w m 2 p a 7 / t m r p a 6 / i n t p a 5 / p w m 1 p a 4 / p w m 0 p a 3 / s d o p a 2 / s d i p a 1 / s c k p a 0 / s c s h t 8 2 a 6 2 0 r 2 0 s s o p - a 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 p b 2 / a n 2 p b 1 / a n 1 p b 0 / a n 0 / p w m 2 p a 7 / t m r p a 6 / i n t p a 5 / p w m 1 p a 4 / p w m 0 p a 3 / s d o p a 2 / s d i p a 1 / s c k p a 0 / s c s p c 7 / a n 1 5 p b 5 / a n 5 p b 6 / a n 6 p b 7 / a n 7 v d d d - / d a t a d + / c l k v 3 3 o o s c o o s c i v s s r e s p c 0 / a n 8 h t 8 2 a 6 2 0 r 2 4 s s o p - a 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 p b 4 / a n 4 p b 5 / a n 5 p b 6 / a n 6 p b 7 / a n 7 v d d d - / d a t a d + / c l k v 3 3 o o s c o o s c i v s s r e s p c 0 / a n 8 p c 1 / a n 9 p b 3 / a n 3 p b 2 / a n 2 p b 1 / a n 1 p b 0 / a n 0 / p w m 2 p a 7 / t m r p a 6 / i n t p a 5 / p w m 1 p a 4 / p w m 0 p a 3 / s d o p a 2 / s d i p a 1 / s c k p a 0 / s c s p c 7 / a n 1 5 p c 6 / a n 1 4 h t 8 2 a 6 2 0 r 2 8 s s o p - a h t 8 2 a 6 2 0 r 3 2 q f n - a 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 2 2 2 3 2 4 2 52 62 72 82 93 03 13 2 p a 1 / s c k p a 2 / s d i p a 3 / s d o p a 4 / p w m 0 p a 5 / p w m 1 p a 6 / i n t p a 7 / t m r p b 0 / a n 0 / p w m 2 p c 0 / a n 8 r e s v s s o s c i o s c o v 3 3 o d + / c l k d - / d a t a v d d p b 7 / a n 7 p b 6 / a n 6 p b 5 / a n 5 p b 4 / a n 4 p b 3 / a n 3 p b 2 / a n 2 p b 1 / a n 1 p c 1 / a n 9 p c 2 / a n 1 0 p c 3 / a n 1 1 p c 4 / a n 1 2 p c 5 / a n 1 3 p c 6 / a n 1 4 p c 7 / a n 1 5 p a 0 / s c s
pin description ht82a520r pin name i/o options description pa0/scs pa1/sck pa2/sdi pa3/sdo pa4/pwm0 pa5/pwm1 pa6/int pa7/tmr i/o pull-high wake-up nmos or cmos bidirectional 8-bit input/output port. each pin can be configured as a wake-up input by a configuration option. software instructions determine if the pin is output or schmitt trigger input. when if output, configuration op - tion may choose cmos or nmos. configuration options determine if the pins have pull-high resistors. the int and tmr pins are pin-shared with pa6 and pa7, respectively. pa0~pa3 are shared with the spi function. pa4~pa5 are shared with pwm0~pwm1. pb0/pwm2 pb1~pb7 i/o pull-high wake-up pb7: i/o or vddio pb0~pb6 power: from vdd or vddio bi-directional 8-bit input/output port. software instructions determine if the pin is a cmos output or schmitt trigger input. configuration options deter - mine if the pins have pull-high resistors. a configuration option determines whether pb7 is an i/o pin or a power supply pin for pb0~pb6. a configuration option determines whether the power supply for pb0~pb6 is sourced from vdd or vddio. pb0 shared with pwm2. pc0~pc7 i/o pull-high wake-up bi-directional 8-bit input/output port. software instructions determine if the pin is a cmos output or schmitt trigger input. configuration options deter - mine if the pins have pull-high resistors. osci osco i o ? osci, osco are connected to an 6mhz or 12mhz crystal/resonator (de - termined by software instructions) for the internal system clock res i ? schmitt trigger reset input, active low vdd ? ? positive power supply d-/data i/o ? usbd- line the usb function is controlled by software control registers d+/clk i/o ? usbd+ line the usb function is controlled by software control registers v33o o ? 3.3v regulator output vss ? ? negative power supply, ground ht82a520r/ht82a620r rev.1.30 4 january 14, 2011
ht82a620r pin name i/o options description pa0/scs pa1/sck pa2/sdi pa3/sdo pa4/pwm0 pa5/pwm1 pa6/int pa7/tmr i/o pull-high wake-up nmos or cmos bi-directional 8-bit input/output port. each bit can be configured as wake-up input by option (bit option). software instructions determine if the pin is output or schmitt trigger input. when if output, configura - tion option may choose cmos or nmos. configuration options de - termine if the pins have pull-high resistors. the tmr and int are pin-shared with pa6 and pa7, respectively. pa0~pa3 are shared with spi function. pa4~pa5 shared with pwm0~pwm1. pb0/an0/pwm2 pb1/an1 pb2/an2 pb3/an3 pb4/an4 pb5/an5 pb6/an6 pb7/an7 i/o pull-high wake-up pb7: i/o or vddio pb0~pb6 power: from vdd or vddio bi-directional 8-bit input/output port. software instructions determine if the pin is a cmos output or schmitt trigger input. configuration op - tions determine if the pins have pull-high resistors. pb is pin shared with the a/d inputs. once a pb line is selected as an a/d input, using software control, the i/o function and pull-high resistor are disabled automatically. a configuration option determines whether pb7 is an i/o pin or a power supply pin for pb0~pb6. a configuration option determines whether the power supply for pb0~pb6 is sourced from vdd or vddio pb0 shared with pwm2. pc0/an8 pc1/an9 pc2/an10 pc3/an11 pc4/an12 pc5/an13 pc6/an14 pc7/an15 i/o pull-high wake-up bi-directional 8-bit input/output port. software instructions determine if the pin is a cmos output or schmitt trigger input. configuration op - tions determine if the pins have pull-high resistors. pc is pin shared with the a/d inputs. once a pb line is selected as an a/d input, using software control, the i/o function and pull-high resistor are disabled automatically osci osco i o ? osci, osco are connected to an external 6mhz or 12mhz crys - tal/resonator, determined by software instructions, for the internal system clock resb i ? schmitt trigger reset input, active low vdd ? ? positive power supply d -/data i/o ? usbd- line the usb function is controlled by a software control register d +/clk i/o ? usbd+ line the usb function is controlled by a software control register v33o o ? 3.3v regulator output vss ? ? negative power supply, ground absolute maximum ratings supply voltage ...........................v ss -0.3v to v ss +6.0v storage t emperature ............................ -50c to 125c input voltage..............................v ss -0.3v to v dd +0.3v operating t emperature............................. -0c to 70c i ol total ..............................................................150ma i oh total............................................................ -100ma t otal power dissipation .....................................500mw note: these are stress ratings only. stresses exceeding the range specified under 2 absolute maximum ratings 2 may cause substantial damage to the device. functional operation of this device at other conditions beyond those listed in the specification is not implied and prolonged exposure to extreme conditions may affect device reliability. ht82a520r/ht82a620r rev.1.30 5 january 14, 2011
d.c. characteristics ta=25 c symbol parameter test conditions min. typ. max. unit v dd conditions v dd operating voltage ? f sys =6mhz 2.2 ? 5.5 v f sys =12mhz 4.0 ? 5.5 v i dd operating current 5v no load, f sys =6mhz, adc off, dac off ? 8 ? ma i sus1 suspend current 5v no load, system halt, usb transceiver, 3.3v register on and clr suspend2 (ucc.4 [22h]) ? 330 ? m a i sus2 suspend current 5v no load, system halt, usb transceiver, 3.3v register on and set suspend2 (ucc.4 [22h]) ? 220 ? m a i stb1 standby current (wdt disabled) 5v no load, system halt, usb disable ? ? 10 ma v il1 input low voltage for i/o ports 5v ? 0 ? 0.3v dd v v ih1 input high voltage for i/o ports 5v ? 0.7v dd ? v dd v v il2 input low voltage (res ) 5v ? 0 ? 0.4v dd v v ih2 input high voltage (res ) 5v ? 0.9v dd ? v dd v v lvr0 low voltage reset 5v ? 1.9 2.0 2.1 v v v33o 3.3v regulator output 5v i v33o =-5ma 3.0 3.3 3.6 v v os* offset error ? ? -2 ? 2 mv i ol i/o port sink current 5v v ol =0.1v dd 10 20 ? ma i oh i/o port source current 5v v oh =0.9v dd -5 -10 ? ma r ph pull-high resistance 5v ? 10 30 50 kw r ph1 pull-high resistance for data 5v ? ? 4.5 ? kw r ph2 pull-high resistance for clk 5v ? ? 4.5 ? kw i adc * additional power consumption if a/d converter is used 5v no load ? 1.5 3.0 ma dnl* a/d differential non-linearity ? ? ? ? 2 lsb inl* a/d integral non-linearity ? ? 2.5 4.0 lsb resolu* resolution ? ? 12 bits note: 2*2for ht82a620r ht82a520r/ht82a620r rev.1.30 6 january 14, 2011
a.c. characteristics ta=25 c symbol parameter test conditions min. typ. max. unit v dd conditions f sys system clock ? 2.2v~5.5v ? 6000 ? khz ? 4.0v~5.5v ? 12000 ? khz f timer timer i/p frequency (tmr) ? f sys =6mhz 0 ? 6000 khz f sys =12mhz 0 ? 12000 khz t wdtosc watchdog oscillator period 5v ? ? 31 ? m s t res external reset low pulse width ? ? 1 ? ? ms t sst system start-up timer period ? wake-up from halt ? 1024 ? t sys t opd option load timer period 5v ? 33 70 140 ms t int interrupt pulse width ? ? 1 ? ? m s t ad * a/d clock period ? ? 1 ? ? m s t adc * a/d conversion time ? ? ? 16 ? t ad t adcs * a/d sample time ? ? ? 8 ? t ad t cs_sk spi scs to sck time ? ? 50 ? ? ns t spick spi clock time ? ? 400 ? ? ns note: t sys =1/f sys 2*2 for ht82a620r ht82a520r/ht82a620r rev.1.30 7 january 14, 2011
ht82a520r/ht82a620r rev.1.30 8 january 14, 2011 system architecture a key factor in the high-performance features of the holtek range of microcontrollers is attributed to the inter - nal system architecture. the range of devices take ad - vantage of the usual features found within risc microcontrollers providing increased speed of operation and enhanced performance. the pipelining scheme is implemented in such a way that instruction fetching and instruction execution are overlapped, hence instructions are effectively executed in one cycle, with the exception of branch or call instructions. an 8-bit wide alu is used in practically all operations of the instruction set. it car - ries out arithmetic operations, logic operations, rotation, increment, decrement, branch decisions, etc. the inter - nal data path is simplified by moving data through the accumulator and the alu. certain internal registers are implemented in the data memory and can be directly or indirectly addressed. the simple addressing methods of these registers along with additional architectural fea - tures ensure that a minimum of external components is required to provide a functional i/o and a/d control sys - tem with maximum reliability and flexibility. clocking and pipelining the main system clock, derived from a crystal/resona - tor is subdivided into four internally generated non-overlapping clocks, t1~t4. the program counter is incremented at the beginning of the t1 clock during which time a new instruction is fetched. the remaining t2~t4 clocks carry out the decoding and execution functions. in this way, one t1~t4 clock cycle forms one instruction cycle. although the fetching and execution of instructions takes place in consecutive instruction cy - cles, the pipelining structure of the microcontroller en - sures that instructions are effectively executed in one instruction cycle. the exception to this are instructions where the contents of the program counter are changed, such as subroutine calls or jumps, in which case the instruction will take one more instruction cycle to execute. for instructions involving branches, such as jump or call instructions, two instruction cycles are required to com - plete instruction execution. an extra cycle is required as the program takes one cycle to first obtain the actual jump or call address and then another cycle to actually execute the branch. the requirement for this extra cycle should be taken into account by programmers in timing sensitive applications. program counter during program execution, the program counter is used to keep track of the address of the next instruction to be executed. it is automatically incremented by one each time an instruction is executed except for instructions, such as 2jmp2 or 2call2 that demand a jump to a non-consecutive program memory address. it must be noted that only the lower 8 bits, known as the program counter low register, are directly addressable by user. when executing instructions requiring jumps to non-consecutive addresses such as a jump instruction, f e t c h i n s t . ( p c ) e x e c u t e i n s t . ( p c - 1 ) f e t c h i n s t . ( p c + 1 ) e x e c u t e i n s t . ( p c ) f e t c h i n s t . ( p c + 2 ) e x e c u t e i n s t . ( p c + 1 ) p c p c + 1 p c + 2 o s c i l l a t o r c l o c k ( s y s t e m c l o c k ) p h a s e c l o c k t 1 p r o g r a m c o u n t e r p h a s e c l o c k t 2 p h a s e c l o c k t 3 p h a s e c l o c k t 4 p i p e l i n i n g system clocking and pipelining f e t c h i n s t . 1 e x e c u t e i n s t . 1 f e t c h i n s t . 2 f l u s h p i p e l i n e 1 2 3 4 5 6 d e l a y : m o v a , [ 1 2 h ] c a l l d e l a y c p l [ 1 2 h ] : : n o p e x e c u t e i n s t . 2 f e t c h i n s t . 3 f e t c h i n s t . 6 e x e c u t e i n s t . 6 f e t c h i n s t . 7 instruction fetching
ht82a520r/ht82a620r rev.1.30 9 january 14, 2011 a subroutine call, interrupt or reset, etc., the microcontroller manages program control by loading the required address into the program counter. for condi - tional skip instructions, once the condition has been met, the next instruction, which has already been fetched during the present instruction execution, is dis - carded and a dummy cycle takes its place while the cor - rect instruction is obtained. the lower byte of the program counter, known as the program counter low register or pcl, is available for program control and is a readable and writeable register. by transferring data directly into this register, a short pro - gram jump can be executed directly, however, as only this low byte is available for manipulation, the jumps are limited to the present page of memory, that is 256 loca - tions. when such program jumps are executed it should also be noted that a dummy cycle will be inserted. the lower byte of the program counter is fully accessi - ble under program control. manipulating the pcl might cause program branching, so an extra cycle is needed to pre-fetch. further information on the pcl register can be found in the special function register section. stack this is a special part of the memory which is used to save the contents of the program counter only. the stack has 6 levels and is neither part of the data nor part of the program space, and is neither readable nor writeable. the activated level is indexed by the stack pointer, sp, and is neither readable nor writeable. at a subroutine call or interrupt acknowledge signal, the con- tents of the program counter are pushed onto the stack. at the end of a subroutine or an interrupt routine, sig- naled by a return instruction, ret or reti, the program counter is restored to its previous value from the stack. after a device reset, the stack pointer will point to the top of the stack. if the stack is full and an enabled interrupt takes place, the interrupt request flag will be recorded but the ac - knowledge signal will be inhibited. when the stack pointer is decremented, by ret or reti, the interrupt will be serviced. this feature prevents stack overflow al - lowing the programmer to use the structure more easily. however, when the stack is full, a call subroutine in - struction can still be executed which will result in a stack overflow. precautions should be taken to avoid such cases which might cause unpredictable program branching. arithmetic and logic unit - alu the arithmetic-logic unit or alu is a critical area of the microcontroller that carries out arithmetic and logic op - erations of the instruction set. connected to the main microcontroller data bus, the alu receives related in - struction codes and performs the required arithmetic or logical operations after which the result will be placed in the specified register. as these alu calculation or oper- ations may result in carry, borrow or other status changes, the status register will be correspondingly up- dated to reflect these changes. the alu supports the following functions. mode program counter bits b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 initial reset 0 0 0 0 0 0 0 0 0 0 0 0 usb interrupt 0 0 0 0 0 0 0 0 0 1 0 0 external interrupt 0 0 0 0 0 0 0 0 1 0 0 0 timer/event counter overflow 0 0 0 0 0 0 0 0 1 1 0 0 spi interrupt 0 0 0 0 0 0 0 1 0 0 0 0 skip program counter + 2 loading pcl pc11 pc10 pc9 pc8 @7 @6 @5 @4 @3 @2 @1 @0 jump, call branch #11 #10 #9 #8 #7 #6 #5 #4 #3 #2 #1 #0 return from subroutine s11 s10 s9 s8 s7 s6 s5 s4 s3 s2 s1 s0 program counter note: pc11~pc8: current program counter bits @7~@0: pcl bits #11~#0: instruction code address bits s11~s0: stack register bits p r o g r a m c o u n t e r s t a c k l e v e l 1 s t a c k l e v e l 2 s t a c k l e v e l 3 s t a c k l e v e l 6 p r o g r a m m e m o r y t o p o f s t a c k s t a c k p o i n t e r b o t t o m o f s t a c k
ht82a520r/ht82a620r rev.1.30 10 january 14, 2011 arithmetic operations: add, addm, adc, adcm, sub, subm, sbc, sbcm, daa logic operations: and, or, xor, andm, orm, xorm, cpl, cpla rotation rra, rr, rrca, rrc, rla, rl, rlca, rlc increment and decrement inca, inc, deca, dec branch decision, jmp, sz, sza, snz, siz, sdz, siza, sdza, call, ret, reti program memory the program memory is the location where the user code or program is stored. the ht82a520r/ ht82a620r is a one-time programmable, otp, mem - ory type device where users can program their applica - tion code into the device. by using the appropriate programming tools, otp devices offer users the flexibil - ity to freely develop their applications which may be use - ful during debug or for products requiring frequent upgrades or program changes. otp devices are also applicable for use in applications that require low or me - dium volume production runs. structure the program memory has a capacity of 4k by 15 bits. the program memory is addressed by the program counter and also contains data, table information and interrupt entries. table data, which can be setup in any location within the program memory, is addressed by separate table pointer registers. special vectors within the program memory, certain locations are re - served for special usage such as reset and interrupts. location 000h this vector is reserved for use by the device reset for program initialisation. after a device reset is initiated, the program will jump to this location and begin execution. location 004h this area is reserved for the usb interrupt service program. if the usb interrupt is activated, the interrupt is enabled and the stack is not full, the program begins execution at location 004h. location 008h this vector is used by the external interrupt. if the int external input pin on the device receives a high to low transition, the program will jump to this location and begin execution, if the interrupt is enabled and the stack is not full. location 00ch this vector is used by the timer counter. if a counter overflow occurs, the program will jump to this location and begin execution if the timer interrupt is enabled and the stack is not full. location 010h this vector is used by serial interface. when 8-bits of data have been received or transmitted successfully from serial interface, the program will jump to this lo - cation and begin execution if the interrupt is enabled and the stack is not full. look-up table any location within the program memory can be defined as a look-up table where programmers can store fixed data. to use the look-up table, one method is to first setup a low byte table pointer by placing the lower order address of the look up data to be retrieved in the low byte table pointer register, tblp. this register defines the lower 8-bit address of the look-up table. after setting up the table pointer, the table data can be retrieved from the current program memory page or last program memory page using the 2 tabrdc[m] 2 or 2 tabrdl [m]2 instructions, respectively. when these in- structions are executed, the lower order table byte from the program memory will be transferred to the user de - fined data memory register [m] as specified in the in - struction. the higher order table data byte from the program memory will be transferred to the tblh special register. any unused bits in this transferred higher order byte will be read as 202. the following diagram illustrates the addressing/data flow of the look-up table: table program example another method is to setup the full table address using both the tblp and tbhp low and high byte table pointer registers to directly address any area in he program memory. in this way any page of data can be accessed directly using the tabrdl instruction. if the tbhp high byte table pointer register is to be used, then it must first be enabled with a configuration option. f f f h 1 5 b i t s i n i t i a l i s a t i o n v e c t o r e x t e r n a l i n t e r r u p t v e c t o r t i m e r / e v e n t c o u n t e r i n t e r r u p t v e c t o r 0 0 0 h 0 0 4 h 0 0 8 h 0 0 c h 0 1 0 h s p i i n t e r r u p t v e c t o r u s b i n t e r r u p t v e c t o r program memory structure
ht82a520r/ht82a620r rev.1.30 11 january 14, 2011 the following example shows how the table pointer and table data is defined and retrieved from the microcontroller. this example uses raw table data lo - cated in the last page which is stored there using the org statement. the value at this org statement is 2f00h2 which refers to the start address of the last page within the 4k program memory of device. the table pointer is setup here to have an initial value of 206h2. this will ensure that the first data read from the data ta - ble will be at the program memory address 2f06h2 or 6 locations after the start of the last page. note that the value for the table pointer is referenced to the first ad - dress of the present page if the 2 tabrdc [m]2 instruc - tion is being used. the high byte of the table data which in this case is equal to zero will be transferred to the tblh register automatically when the 2 tabrdl [m]2 in - struction is executed. instruction table location bits b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 tabrdc [m] pc11 pc10 pc9 pc8 @7 @6 @5 @4 @3 @2 @1 @0 tabrdl [m] 1 1 1 1 @7 @6 @5 @4 @3 @2 @1 @0 table location note: pc11~pc8: current program counter bits tbhp register bit3~bit0 when tbhp is enabled @7~@0: table pointer tblp bits p r o g r a m m e m o r y p r o g r a m c o u n t e r h i g h b y t e t b l p t b l h s p e c i f i e d b y [ m ] t a b l e c o n t e n t s h i g h b y t e t a b l e c o n t e n t s l o w b y t e t a b l e r e a d - t b l p o n l y tempreg1 db ? ; temporary register #1 tempreg2 db ? ; temporary register #2 : : mov a,06h ; initialise table pointer - note that this address ; is referenced mov tblp,a ; to the last page or present page : : tabrdl tempreg1 ; transfers value in table referenced by table pointer ; to tempregl ; data at prog. memory address 2f06h2 transferred to ; tempreg1 and tblh dec tblp ; reduce value of table pointer by one tabrdl tempreg2 ; transfers value in table referenced by table pointer ; to tempreg2 ; data at prog.memory address 2f05h2 transferred to ; tempreg2 and tblh ; in this example the data 21ah2 is transferred to ; tempreg1 and data 20fh2 to register tempreg2 ; the value 200h2 will be transferred to the high byte ; register tblh : : org f00h ; sets initial address of last page dc 00ah, 00bh, 00ch, 00dh, 00eh, 00fh, 01ah, 01bh : : p r o g r a m m e m o r y t b l p t b l h s p e c i f i e d b y [ m ] h i g h b y t e o f t a b l e c o n t e n t s l o w b y t e o f t a b l e c o n t e n t s t a b l e r e a d - t b l p / t b h p t b h p
ht82a520r/ht82a620r rev.1.30 12 january 14, 2011 because the tblh register is a read-only register and cannot be restored, care should be taken to ensure its protection if both the main routine and interrupt service routine use the table read instructions. if using the table read instructions, the interrupt service routines may change the value of tblh and subsequently cause er - rors if used again by the main routine. as a rule it is rec - ommended that simultaneous use of the table read instructions should be avoided. however, in situations where simultaneous use cannot be avoided, the inter - rupts should be disabled prior to the execution of any main routine table-read instructions. note that all table related instructions require two instruction cycles to complete their operation. data memory the data memory is a volatile area of 8-bit wide ram internal memory and is the location where temporary in - formation is stored. divided into two sections, the first of these is an area of ram where special function registers are located. these registers have fixed locations and are necessary for correct operation of the device. many of these registers can be read from and written to di - rectly under program control, however, some remain protected from user manipulation. the second area of data memory is reserved for general purpose use. all locations within this area are read and write accessible under program control. structure the two sections of data memory, the special purpose and general purpose data memory are located at con- secutive locations. all are implemented in ram and are 8 bits wide but the length of each memory section is dic- tated by the type of microcontroller chosen. the start address of the data memory for all devices is the ad - dress 2 00h 2 . registers which are common to all microcontrollers, such as acc, pcl, etc., have the same data memory address. general purpose data memory all microcontroller programs require an area of read/write memory where temporary data can be stored and retrieved for use later. it is this area of ram memory that is known as general purpose data memory. this area of data memory is fully accessible by the user pro - gram for both read and write operations. by using the 2 set [m].i2 and 2 clr [m].i2 instructions individual bits can be set or reset under program control giving the user a large range of flexibility for bit manipulation in the data memory. 0 0 h 6 0 h f f h 5 f h s p e c i a l p u r p o s e d a t a m e m o r y g e n e r a l p u r p o s e d a t a m e m o r y data memory structure note: most of the data memory bits can be directly manipulated using the 2 set [m].i2 and 2clr [m].i2 with the exception of a few dedicated bits. the data memory can also be accessed through the memory pointer register mp. 0 0 h 0 1 h 0 2 h 0 3 h 0 4 h 0 5 h 0 6 h 0 7 h 0 8 h 0 9 h 0 a h 0 b h 0 c h 0 d h 0 e h 0 f h 1 0 h 1 1 h 1 2 h 1 3 h 1 4 h 1 5 h 1 6 h 1 7 h 1 8 h 1 9 h 1 a h 1 b h 1 c h 1 d h 1 e h 1 f h 2 0 h 2 1 h 2 2 h 2 3 h 2 4 h 2 5 h 2 6 h 2 7 h 2 8 h 2 9 h 2 a h 2 b h 2 c h 2 d h : u n u s e d r e a d a s " 0 0 " i a r 0 m p 0 i a r 1 m p 1 a c c p c l t b l p t b l h w d t s s t a t u s i n t c 0 t m r h t m r l t m r c p a p a c p b p b c p c p c c u s b _ s t a t u i n t i n t c 1 t b h p u s c u s r u c c a w r s t a l l s i e s m i s c u f i e n f i f o 0 f i f o 1 f i f o 2 f i f o 3 2 e h 2 f h 3 0 h 3 1 h 3 2 h 3 3 h 3 4 h 3 5 h 3 6 h 3 7 h 3 8 h 3 9 a 3 a h 3 b h 3 c h 3 d h 3 e h 3 f h 4 0 h 4 1 h 4 2 h 4 3 h 4 4 h 4 5 h 4 6 h 4 7 h 4 8 h 4 9 h 4 a h 4 b h 4 c h 4 d h 4 e h 4 f h 5 0 h 5 1 h 5 2 h 5 3 h 5 4 h 5 5 h 5 6 h 5 7 h 5 8 h 5 9 h 5 a h u f o e n u f c 0 s b c r s b d r a d r l * a d r h * a d c r * a d s r * p w m b r 0 p w m 0 d r l p w m 0 d r h p w m b r 1 p w m 1 d r l p w m 1 d r h p w m b r 2 p w m 2 d r l p w m 2 d r h s p i r " * " f o r h t 8 2 a 6 2 0 r
ht82a520r/ht82a620r rev.1.30 13 january 14, 2011 special purpose data memory this area of data memory is where registers, necessary for the correct operation of the microcontroller, are stored. most of the registers are both readable and writable but some are protected and are readable only, the details of which are located under the relevant spe - cial function register section. note that for locations that are unused, any read instruction to these addresses will return the value 200h2. special function registers to ensure successful operation of the microcontroller, certain internal registers are implemented in the data memory area. these registers ensure correct operation of internal functions such as timers, interrupts, etc., as well as external functions such as i/o data control. the location of these registers within the data memory be - gins at the address 00h. any unused data memory lo - cations between these special function registers and the point where the general purpose memory begins is re - served and attempting to read data from these locations will return a value of 00h. indirect addressing register - iar0, iar1 the iar0 and iar1 register, although having their loca - tions in normal ram register space, do not actually physically exist as normal registers. the method of indi - rect addressing for ram data manipulation uses these indirect addressing registers and memory pointers, in contrast to direct memory addressing, where the actual memory address is specified. actions on the iar0 and iar1 registers will result in no actual read or write opera - tion to these registers but rather to the memory location specified by their corresponding memory pointer, mp0 or mp1. acting as a pair, iar0 and mp0 can together only access data from bank 0, while the iar1 and mp1 register pair can access data from both bank 0 and bank 1. as the indirect addressing registers are not physically implemented, reading the indirect ad - dressing registers indirectly will return a result of 200h2 and writing to the registers indirectly will result in no op - eration. memory pointer - mp0, mp1 for all devices, two memory pointers, known as mp0 and mp1 are provided. these memory pointers are physically implemented in the data memory and can be manipulated in the same way as normal registers pro - viding a convenient way with which to address and track data. when any operation to the relevant indirect ad - dressing registers is carried out, the actual address that the microcontroller is directed to, is the address speci - fied by the related memory pointer. data .section data adres1 db ? adres2 db ? adres3 db ? adres4 db ? block db ? code .section at 0 code org 00h start: mov a,04h ; setup size of block mov block,a mov a,offset adres1; accumulator loaded with first ram address mov mp0,a ; setup memory pointer with first ram address loop: clr iar0 ; clear the data at address defined by mp0 inc mp0 ; increment memory pointer sdz block ; check if last memory location has been cleared jmp loop continue: the important point to note here is that in the example shown above, no reference is made to specific data memory ad - dresses.
ht82a520r/ht82a620r rev.1.30 14 january 14, 2011 accumulator - acc the accumulator is central to the operation of any microcontroller and is closely related with operations carried out by the alu. the accumulator is the place where all intermediate results from the alu are stored. without the accumulator it would be necessary to write the result of each calculation or logical operation such as addition, subtraction, shift, etc., to the data memory resulting in higher programming and timing overheads. data transfer operations usually involve the temporary storage function of the accumulator; for example, when transferring data between one user defined register and another, it is necessary to do this by passing the data through the accumulator as no direct transfer between two registers is permitted. program counter low register - pcl to provide additional program control functions, the low byte of the program counter is made accessible to pro - grammers by locating it within the special purpose area of the data memory. by manipulating this register, direct jumps to other program locations are easily imple - mented. loading a value directly into this pcl register will cause a jump to the specified program memory lo - cation, however, as the register is only 8-bit wide, only jumps within the current program memory page are per - mitted. when such operations are used, note that a dummy cycle will be inserted. look-up table registers - tblp, tbhp, tblh these three special function registers are used to con- trol operation of the look-up table which is stored in the program memory. tblp and tbhp are the table pointer low and high byte registers and indicate the location where the table data is located. there value must be setup before any table read commands are executed. their value can be changed, for example using the 2inc2 or 2dec2 instructions, allowing for easy table data pointing and reading. tblh is the location where the high order byte of the table data is stored after a table read data instruction has been executed. note that the lower order table data byte is transferred to a user de - fined location. status register - status this 8-bit register contains the zero flag (z), carry flag (c), auxiliary carry flag (ac), overflow flag (ov), power down flag (pdf), and watchdog time-out flag (to). these arithmetic/logical operation and system manage - ment flags are used to record the status and operation of the microcontroller. with the exception of the to and pdf flags, bits in the status register can be altered by instructions like most other registers. any data written into the status register will not change the to or pdf flag. in addition, opera - tions related to the status register may give different re - sults due to the different instruction operations. the to flag can be affected only by a system power-up, a wdt time-out or by executing the 2 clr wdt2 or 2 halt2 in - struction. the pdf flag is affected only by executing the 2 halt2 or 2 clr wdt2 instruction or during a system power-up. the z, ov, ac and c flags generally reflect the status of the latest operations. c is set if an operation results in a carry during an ad - dition operation or if a borrow does not take place dur - ing a subtraction operation; otherwise c is cleared. c is also affected by a rotate through carry instruction. ac is set if an operation results in a carry out of the low nibbles in addition, or no borrow from the high nib - ble into the low nibble in subtraction; otherwise ac is cleared. z is set if the result of an arithmetic or logical operation is zero; otherwise z is cleared. ov is set if an operation results in a carry into the high- est-order bit but not a carry out of the highest-order bit, or vice versa; otherwise ov is cleared. pdf is cleared by a system power-up or executing the 2 clr wdt2 instruction. pdf is set by executing the 2halt2 instruction. to is cleared by a system power-up or executing the 2 clr wdt2 or 2halt2 instruction. to is set by a wdt time-out. t o p d f o v z a c c s t a t u s r e g i s t e r a r i t h m e t i c / l o g i c o p e r a t i o n f l a g s c a r r y f l a g a u x i l i a r y c a r r y f l a g z e r o f l a g o v e r f l o w f l a g s y s t e m m a n a g e m e n t f l a g s p o w e r d o w n f l a g w a t c h d o g t i m e - o u t f l a g n o t i m p l e m e n t e d , r e a d a s " 0 " b 7 b 0 status register
ht82a520r/ht82a620r rev.1.30 15 january 14, 2011 in addition, on entering an interrupt sequence or execut - ing a subroutine call, the status register will not be pushed onto the stack automatically. if the contents of the status registers are important and if the interrupt rou - tine can change the status register, precautions must be taken to correctly save it. interrupt control registers - intc0, intc1 the microcontrollers provide one external interrupts, one internal timer/event counter overflow interrupt, one spi interrupt and one usb interrupt. by setting various bits within these registers using standard bit manipula - tion instructions, the enable/disable function of each in - terrupt can be independently controlled. a master interrupt bit within this register, the emi bit, acts like a global enable/disable and is used to set all of the inter - rupt enable bits on or off. this bit is cleared when an in - terrupt routine is entered to disable further interrupt and is set by executing the 2 reti 2 instruction. timer/event counter registers - tmrh, tmrl, tmrc all devices possess one internal 16-bit count-up timer. an associated register pair known as tmrl/tmrh are the locations where the timer 16-bit values are located. these registers can also be preloaded with fixed data to allow different time intervals to be setup. associated con - trol registers, known as tmrc, contains the setup infor - mation for the timers, which determines in what mode the timer is to be used as well as containing the timer on/off control function. input/output ports and control registers within the area of special function registers, the i/o registers and their associated control registers play a prominent role. all i/o ports have a designated register correspondingly labeled as pa, pb, pc. these labeled i/o registers are mapped to specific addresses within the data memory as shown in the data memory table, which are used to transfer the appropriate output or in - put data on that port. with each i/o port there is an asso - ciated control register labeled pac, pbc, pcc, also mapped to specific addresses with the data memory. the control register specifies which pins of that port are set as inputs and which are set as outputs. to setup a pin as an input, the corresponding bit of the control reg - ister must be set high, for an output it must be set low. during program initialisation, it is important to first setup the control registers to specify which pins are outputs and which are inputs before reading data from or writing data to the i/o ports. one flexible feature of these regis - ters is the ability to directly program single bits using the 2 set [m].i2 and 2 clr [m].i2 instructions. the ability to change i/o pins from output to input and vice versa by manipulating specific bits of the i/o control registers dur - ing normal program operation is a useful feature of these devices. input/output ports holtek microcontrollers offer considerable flexibility on their i/o ports. with the input or output designation of ev - ery pin fully under user program control, pull-high op - tions for all ports and wake-up options on certain pins, the user is provided with an i/o structure to meet the needs of a wide range of application possibilities. depending upon which package is chosen, the microcontroller provides up to 24 bidirectional input/out- put lines labeled with port names pa, pb, pc. this register is mapped to the data memory with an ad- dresses as shown in the special purpose data memory table. seven of these i/o lines can be used for input and output operations and one line as an input only. for in - put operation, these ports are non-latching, which v d d m u x w a k e - u p s e l e c t s y s t e m w a k e - u p r e a d d a t a r e g i s t e r d q c k s d q c k s c o n t r o l b i t d a t a b u s w r i t e c o n t r o l r e g i s t e r c h i p r e s e t r e a d c o n t r o l r e g i s t e r w r i t e d a t a r e g i s t e r d a t a b i t i / o p i n q q w e a k p u l l - u p p u l l - h i g h s e l e c t generic input/output ports
ht82a520r/ht82a620r rev.1.30 16 january 14, 2011 means the inputs must be ready at the t2 rising edge of instruction 2 mov a,[m]2 , where m denotes the port ad - dress. for output operation, all the data is latched and remains unchanged until the output latch is rewritten. pull-high resistors many product applications require pull-high resistors for their switch inputs usually requiring the use of an exter - nal resistor. to eliminate the need for these external re - sistors, i/o pins, when configured as an input have the capability of being connected to an internal pull-high re - sistor. the pull-high resistors are selectable via configu - ration options and are implemented using weak pmos transistors. each pin on all of i/o can be selected indi - vidually to have this pull-high resistors feature and each nibble on each of the other ports. port pin wake-up if the halt instruction is executed, the device will enter the power down mode, where the system clock will stop resulting in power being conserved, a feature that is im - portant for battery and other low-power applications. various methods exist to wake-up the microcontroller, one of which is to change the logic condition on one of the port pins from high to low. after a halt instruction forces the microcontroller into entering the power down mode, the processor will remain in a low-power state un - til the logic condition of the selected wake-up pin on the port pin changes from high to low. this function is espe - cially suitable for applications that can be woken up via external switches. each pin on pa has a bit wake-up configuration option and pb, pc have nibble wake-up configuration options. i/o port control registers each i/o port has its own control register pac, pbc, pcc, to control the input/output configuration. with this control register, each cmos output or input with or with - out pull-high resistor structures can be reconfigured dy - namically under software control. each of the i/o ports is directly mapped to a bit in its associated port control reg - ister. note that several pins can be setup to have nmos outputs using configuration options. for the i/o pin to function as an input, the corresponding bit of the control register must be written as a 212 . this will then allow the logic state of the input pin to be di - rectly read by instructions. when the corresponding bit of the control register is written as a 202 , the i/o pin will be setup as an output. if the pin is currently setup as an output, instructions can still be used to read the output register. however, it should be noted that the program will in fact only read the status of the output data latch and not the actual logic status of the output pin. port b vddio function the output drivers of most i/o pins use the vdd power supply line as their high voltage level. in this device pins pb0~pb6 can use a different voltage, other than vdd as their high level. this is supplied externally on pin pb7. this function is selected using a configuration option. pin-shared functions the flexibility of the microcontroller range is greatly en - hanced by the use of pins that have more than one func - tion. limited numbers of pins can force serious design constraints on designers but by supplying pins with multi-functions, many of these difficulties can be over - come. for some pins, the chosen function of the multi-function i/o pins is set by configuration options while for others the function is set by application pro - gram control. external interrupt input the external interrupt pin int is pin-shared with the i/o pin pa6. for applications not requiring an external interrupt input, the pin-shared external interrupt pin can be used as a normal i/o pin, however to do this, the external interrupt enable bits in the intc0 register must be disabled. external timer clock inputs the external timer pin tmr is pin-shared with an i/o pin. to configure this pin to operate as a timer input, the corresponding control bit in the timer control regis - ter must be correctly set. for applications that do not require an external timer input, this pin can be used as a normal i/o pin. note that if used as a normal i/o pin the timer mode control bits in the timer control register must select the timer mode, which has an internal clock source, to prevent the input pin from interfering with the timer operation. pwm outputs the device contains three pwm outputs which are pin-shared with i/o pins. the pwm output functions are chosen via registers. note that the corresponding bit of the port control register, pac and pbc, must setup the pin as an output to enable the pwm output. if the pac and pbc port control register has setup the pin as an input, then the pin will function as a normal logic input with the usual pull-high option, even if the pwm configuration option has been selected.
ht82a520r/ht82a620r rev.1.30 17 january 14, 2011 a/d inputs - ht82a620r this device has 16 a/d converter inputs depending upon which package type is chosen. all of these ana - log inputs are pin-shared with i/o pins on port b and port c. if these pins are to be used as a/d inputs and not as normal i/o pins then the corresponding bits in the a/d converter control register, acsr, must be properly set. there are no configuration options asso - ciated with the a/d function. if used as i/o pins, then full pull-high resistor configuration options remain, however if used as a/d inputs then any pull-high resis - tor options associated with these pins will be automat - ically disconnected. i/o pin structures the vast range of i/o functions and pin-shared options results in a huge variety of i/o pin structure types. for this reason the generic input/output port diagram pro - vided here is for general reference only. as the exact logical construction of the i/o pin will differ from the drawing, they are supplied as a guide only to assist with the functional understanding of the basic i/o pins. programming considerations within the user program, one of the first things to con - sider is port initialisation. after a reset, all of the data and port control register will be set high. this means that all i/o pins will default to an input state, the level of which depends on the other connected circuitry and whether pull-high options have been selected. if the pac, pbc, pcc port control register, are then programmed to setup some pins as outputs, these output pins will have an ini- tial high output value unless the associated pa, pb, pc port data registers are first programmed. selecting which pins are inputs and which are outputs can be achieved byte-wide by loading the correct value into the port control register or by programming individual bits in the port control register using the 2 set [m].i2 and 2clr [m].i2 instructions. note that when using these bit control instructions, a read-modify-write operation takes place. the microcontroller must first read in the data on the en - tire port, modify it to the required new bit values and then rewrite this data back to the output ports. the ports have the additional capability of providing wake-up functions. when the device is in the power down mode, various methods are available to wake the device up. one of these is a high to low transition of any of the port pins. single or multiple pins on the ports can be setup to have this function. timer/event counters the provision of timers form an important part of any microcontroller, giving the designer a means of carrying out time related functions. this device contains a single count-up timer of 16-bit capacity. as each timer has three different operating modes, they can be configured to operate as a general timer, an external event counter or as a pulse width measurement device. there are two types of registers related to the timer/event counters. the first is the register that con - tain the actual value of the timer/event counter and into which an initial value can be preloaded, and is known as tmrh, tmrl. reading from this register retrieves the contents of the timer/event counter. the second type of associated register is the timer control register, which defines the timer options and determines how the timer/event counter is to be used, and has the name tmrc. this device can have the timer clocks config - ured to come from the internal clock sources. in addi - tion, the timer clock sources can also be configured to come from the external timer pins. the external clock source is used when the timer/event counter is in the event counting mode, the clock source being provided on the external timer pin. the external timer pin has the name tmr. depending upon the con - dition of the te bit in the timer control register, each high to low, or low to high transition on the external timer input pin will increment the timer/event counter by one. configuring the timer/event counter input clock source the timer/event counter s clock can originate from vari- ous sources. the instruction clock source (system clock source divided by 4) is used when the timer/event coun - ter is in the timer mode or in the pulse width measure - ment mode. the external clock source is used when the timer/event counter is in the event counting mode, the clock source being provided on the external timer pin, tmr. depending upon the condition of the te bit, each high to low, or low to high transition on the external timer pin will increment the counter by one. timer registers - tmrl, tmrh the timer registers are special function registers located in the special purpose ram data memory and are the places where the actual timer values are stored. the timer registers are known as tmrl and tmrh. the value in the timer registers increases by one each time an internal clock pulse is received or an external transi - tion occurs on the external timer pin. the timer will count from the initial value loaded by the preload register to the full count of ffffh for the 16-bit timer at which point the timer overflows and an internal interrupt signal is generated. the timer value will then be reset with the ini - tial preload register value and continue counting. t 1 t 2 t 3 t 4 t 1 t 2 t 3 t 4 w r i t e t o p o r t r e a d f r o m p o r t s y s t e m c l o c k p o r t d a t a read/write timing
ht82a520r/ht82a620r rev.1.30 18 january 14, 2011 to achieve a maximum full range count of ffffh, the preload registers must first be cleared to all zeros. it should be noted that after power-on, the preload register will be in an unknown condition. note that if the timer/event counter is switched off and data is written to its preload registers, this data will be immediately writ - ten into the actual timer registers. however, if the timer/event counter is enabled and counting, any new data written into the preload data registers during this period will remain in the preload registers and will only be written into the timer registers the next time an over - flow occurs. for the 16-bit timer/event counter which has both low byte and high byte timer registers, accessing these reg - isters is carried out in a specific way. it must be note when using instructions to preload data into the low byte timer register, namely tmrl, the data will only be placed in a low byte buffer and not directly into the low byte timer register. the actual transfer of the data into the low byte timer register is only carried out when a write to its associated high byte timer register, namely tmrh, is executed. on the other hand, using instruc - tions to preload data into the high byte timer register will result in the data being directly written to the high byte timer register. at the same time the data in the low byte buffer will be transferred into its associated low byte timer register. for this reason, the low byte timer regis - ter should be written first when preloading data into the 16-bit timer registers. it must also be noted that to read the contents of the low byte timer register, a read to the high byte timer register must be executed first to latch the contents of the low byte timer register into its associ - ated low byte buffer. after this has been done, the low byte timer register can be read in the normal way. note that reading the low byte timer register will result in read - ing the previously latched contents of the low byte buffer and not the actual contents of the low byte timer register. timer control register - tmrc the flexible features of the holtek microcontroller timer/event counters enable them to operate in three different modes, the options of which are determined by the contents of their control register, which has the name tmrc. it is the timer control register together with its corresponding timer register that control the full operation of the timer/event counter. before the timer/event counter can be used, it is essential that the timer control register is fully programmed with the right data to ensure its correct operation, a process that is normally carried out during program initialisation. t m r t e t i m e r / e v e n t c o u n t e r m o d e c o n t r o l 1 6 - b i t p r e l o a d r e g i s t e r d a t a b u s r e l o a d o v e r f l o w t o i n t e r r u p t l o w b y t e b u f f e r t m 1 t m 0 t o n h i g h b y t e l o w b y t e 1 6 - b i t t i m e r / e v e n t c o u n t e r f s y s / 4 16-bit timer/event counter structure n o t i m p l e m e n t e d , r e a d a s " 0 " t i m e r / e v e n t c o u n t e r c o u n t i n g e n a b l e 1 : e n a b l e 0 : d i s a b l e o p e r a t i n g m o d e s e l e c t t m 1 0 0 1 1 t m 0 0 1 0 1 n o m o d e a v a i l a b l e e v e n t c o u n t e r m o d e t i m e r m o d e p u l s e w i d t h m e a s u r e m e n t m o d e n o t i m p l e m e n t e d , r e a d a s " 0 " b 7 t e t o n t m 0 t m 1 b 0 t m r c r e g i s t e r e v e n t c o u n t e r a c t i v e e d g e s e l e c t 1 : c o u n t o n f a l l i n g e d g e 0 : c o u n t o n r i s i n g e d g e p u l s e w i d t h m e a s u r e m e n t a c t i v e e d g e s e l e c t 1 : s t a r t c o u n t i n g o n r i s i n g e d g e , s t o p o n f a l l i n g e d g e 0 : s t a r t c o u n t i n g o n f a l l i n g e d g e , s t o p o n r i s i n g e d g e timer/event counter control register
ht82a520r/ht82a620r rev.1.30 19 january 14, 2011 to choose which of the three modes the timer/event counter is to operate in, either in the timer mode, the event counting mode or the pulse width measurement mode, bits 7 and 6 of the timer control register, which are known as the bit pair tm1/tm0, must be set to the required logic levels. the timer/event counter on/off bit, which is bit 4 of the timer control register and known as ton, provides the basic on/off control of the timer/event counter. setting the bit high allows the timer/event counter to run, clearing the bit stops it run - ning. if the timer/event counter is in the event count or pulse width measurement mode, the active transition edge level type is selected by the logic level of bit 3 of the timer control register which is known as te. configuring the timer mode in this mode, the timer/event counter can be utilised to measure fixed time intervals, providing an internal inter - rupt signal each time the timer/event counter over - flows. to operate in this mode, the operating mode select bit pair, tm1 or tm0, in the timer control regis - ter must be set to the correct value as shown. control register operating mode select bits for the timer mode bit7 bit6 1 0 in this mode the internal clock, f sys /4 is used as the in - ternal clock for the timer/event counter. after the other bits in the timer control register have been setup, the enable bit ton, which is bit 4 of the timer control reg - ister, can be set high to enable the timer/event counter to run. each time an internal clock cycle occurs, the timer/event counter increments by one. when it is full and overflows, an interrupt signal is generated and the timer/event counter will reload the value already loaded into the preload register and continue counting. the interrupt can be disabled by ensuring that the timer/event counter interrupt enable bit in the interrupt control register, intc0, is reset to zero. configuring the event counter mode in this mode, a number of externally changing logic events, occurring on the external timer pin, can be re - corded by the timer/event counter. to operate in this mode, the operating mode select bit pair, tm1/tm0, in the timer control register must be set to the correct value as shown. control register operating mode select bits for the event counter mode bit7 bit6 0 1 in this mode, the external timer pin, tmr, is used as the timer/event counter clock source, however it is not di - vided by the internal prescaler. after the other bits in the timer control register have been setup, the enable bit ton, which is bit 4 of the timer control register, can be set high to enable the timer/event counter to run. if the active edge select bit te, which is bit 3 of the timer control register, is low, the timer/event counter will in - crement each time the external timer pin receives a low to high transition. if the active edge select bit is high, the counter will increment each time the external timer pin receives a high to low transition. when it is full and overflows, an interrupt signal is generated and the timer/event counter will reload the value already loaded into the preload register and continue counting. the interrupt can be disabled by ensuring that the timer/event counter interrupt enable bit in the interrupt control register, intc0, is reset to zero. as the external timer pin is an independent pin and not shared with an i/o pin, the only thing to ensure the timer operate as an event counter is to ensure that the oper- ating mode select bits in the timer control register place the timer/event counter in the event counting mode. it should be noted that in the event counting mode, even if the microcontroller is in the power down mode, the timer/event counter will continue to record externally changing logic events on the timer input pin. as a result when the timer overflows it will generate a timer interrupt and corresponding wake-up source. i n c r e m e n t t i m e r c o n t r o l l e r p r e s c a l e r o u t p u t t i m e r + 1 t i m e r + 2 t i m e r + n t i m e r + n + 1 timer mode timing chart t i m e r + 2 e x t e r n a l e v e n t i n c r e m e n t t i m e r c o u n t e r t i m e r + 3 t i m e r + 1 event counter mode timing chart
ht82a520r/ht82a620r rev.1.30 20 january 14, 2011 configuring the pulse width measurement mode in this mode, the timer/event counter can be utilised to measure the width of external pulses applied to the ex - ternal timer pin. to operate in this mode, the operating mode select bit pair, tm1 or tm0, in the timer control register must be set to the correct value as shown. control register operating mode select bits for the pulse width measure - ment mode bit7 bit6 1 1 in this mode the internal clock, f sys /4 is used as the in - ternal clock for the 16-bit timer/event counters. after the other bits in the timer control register have been setup, the enable bit ton, which is bit 4 of the timer control register, can be set high to enable the timer/event counter, however it will not actually start counting until an active edge is received on the external timer pin. if the active edge select bit te , which is bit 3 of the timer control register, is low, once a high to low transi - tion has been received on the external timer pin, tmr, the timer/event counter will start counting until the ex - ternal timer pin returns to its original high level. at this point the enable bit will be automatically reset to zero and the timer/event counter will stop counting. if the active edge select bit is high, the timer/event counter will begin counting once a low to high transition has been received on the external timer pin and stop count - ing when the external timer pin returns to its original low level. as before, the enable bit will be automatically re- set to zero and the timer/event counter will stop count- ing. it is important to note that in the pulse width measurement mode, the enable bit is automatically re- set to zero when the external control signal on the exter - nal timer pin returns to its original level, whereas in the other two modes the enable bit can only be reset to zero under program control. the residual value in the timer/event counter, which can now be read by the program, therefore represents the length of the pulse received on the external timer pin. as the enable bit has now been reset, any further transitions on the external timer pin will be ignored. not until the enable bit is again set high by the program can the timer begin further pulse width measurements. in this way, single shot pulse measurements can be easily made. it should be noted that in this mode the timer/event counter is controlled by logical transitions on the external timer pin and not by the logic level. when the timer/event counter is full and overflows, an interrupt signal is gener - ated and the timer/event counter will reload the value al - ready loaded into the preload register and continue counting. the interrupt can be disabled by ensuring that the timer/event counter interrupt enable bit in the inter - rupt control register, intc0, is reset to zero. i/o interfacing the timer/event counter, when configured to run in the event counter or pulse width measurement mode, re - quires the use of an external pin for correct operation. this is implemented by ensuring that the mode select bits in the timer/event counter control register, select either the event counter or pulse width measurement mode. programming considerations when configured to run in the timer mode, the instruc - tion clock (system clock divided by 4) is used as the in - ternal timer clock source for the two 16-bit timers and is therefore synchronized with the overall operation of the microcontroller. in this mode, when the appropriate timer register is full, the microcontroller will generate an internal interrupt signal directing the program flow to the respective internal interrupt vector. for the pulse width measurement mode, the instruction clock is also used as the timer clock source but the timer will only run when the correct logic condition appears on the external timer input pin. as this is an external event and not synchro - nised with the internal timer clock, the microcontroller will only see this external event when the next timer clock pulse arrives. as a result there may be small differ - ences in measured values requiring programmers to take this into account during programming. the same applies if the timer is configured to be in the event count - ing mode which again is an external event and not syn - chronised with the internal system or timer clock. + 1 + 2 + 3 + 4 t i m e r e x t e r n a l t i m e r p i n i n p u t t o n ( w i t h t e = 0 ) p r e s c a l e r o u t p u t i n c r e m e n t t i m e r c o u n t e r p r e s c a l e r o u t p u t i s s a m p l e d a t e v e r y f a l l i n g e d g e o f t 1 . pulse width measure mode timing chart
ht82a520r/ht82a620r rev.1.30 21 january 14, 2011 when the timer/event counter is read or if data is written to the preload registers, the clock is inhibited to avoid er - rors, however as this may result in a counting error, this should be taken into account by the programmer. care must be taken to ensure that the timers are properly in - itialised before using them for the first time. the associ - ated timer interrupt enable bits in the interrupt control register must be properly set otherwise the internal inter - rupt associated with the timer will remain inactive. the edge select, timer mode and clock source control bits in timer control register must also be correctly set to ensure the timer is properly configured for the required applica - tion. it is also important to ensure that an initial value is first loaded into the timer register before the timer is switched on; this is because after power-on the initial value of the timer register is unknown. after the timer has been initialised the timer can be turned on and off by con - trolling the enable bit in the timer control register. note that setting the timer enable bit high to turn the timer on, should only be executed after the timer mode bits have been properly setup. setting the timer enable bit high to - gether with a mode bit modification, may lead to improper timer operation if executed as a single timer control regis - ter byte write instruction. when the timer/event counter overflows, its corre - sponding interrupt request flag in the interrupt control register will be set. if the timer interrupt is enabled this will in turn generate an interrupt signal. however irre - spective of whether the timer interrupt is enabled or not, a timer/event counter overflow will also generate a wake-up signal if the device is in a power-down condi - tion. this situation may occur if the timer/event counter is in the event counting mode and if the external signal continues to change state. in such a case, the timer/event counter will continue to count these exter - nal events and if an overflow occurs the device will be woken up from its power-down condition. to prevent such a wake-up from occurring, the timer interrupt re - quest flag should first be set high before issuing the halt instruction to enter the power down mode. timer program example this program example shows how the timer/event counter registers are setup, along with how the inter - rupts are enabled and managed. note how the timer/event counter is turned on, by setting bit 4 of the timer control register. the timer/event counter can be turned off in a similar way by clearing the same bit. this example program sets the timer/event counter tobe in the timer mode, which uses the internal system clock as the clock source. org 04h ; usb interrupt vector reti org 08h ; external interrupt vector reti org 0ch ; timer/event counter interrupt vector jmp tmr0int ; jump here when timer/event counter overflows org 010h ; spi interrupt vector reti : org 20h ; main program : ;internal timer/event counter interrupt routine tmrint: : ; timer/event counter main program placed here : reti : begin: ;setup timer/event counter registers mov a,0e8h ; setup low byte preload value for timer/event counter mov tmrl,a ; low byte must be setup before high byte mov a,09bh ; setup high byte preload value for timer/event counter mov tmrh,a ; mov a,080h ; setup timer control register tmrc mov tmrc,a ; timer/event counter clock source is fsys/4 ; setup interrupt register mov a,009h ; enable master interrupt and timer interrupts mov intc0,a : set tmrc.4 ; start timer/event counter _ note mode bits must be previously setup
ht82a520r/ht82a620r rev.1.30 22 january 14, 2011 a u t o m a t i c a l l y c l e a r e d b y i s r m a n u a l l y s e t o r c l e a r e d b y s o f t w a r e u s b i n t e r r u p t r e q u e s t f l a g u s b f e u i e m i p r i o r i t y i n t e r r u p t p o l l i n g h i g h a u t o m a t i c a l l y d i s a b l e d b y i s r c a n b e e n a b l e d m a n u a l l y t i m e r / e v e n t c o u n t e r o v e r f l o w i n t e r r u p t r e q u e s t f l a g t f e e i l o w s p i i n t e r r u p t r e q u e s t f l a g s i f e s i i e x t e r n a l i n t e r r u p t r e q u e s t f l a g e i f e t i interrupt structure interrupts interrupts are an important part of any microcontroller system. when an external interrupt pin transition or an internal function such as a timer/event counter over - flow, an usb interrupt, or transmission or reception of spi data occurs, their corresponding interrupt will en - force a temporary suspension of the main program al - lowing the microcontroller to direct attention to their respective needs. each device contains a single exter - nal interrupt and several internal interrupts functions. the external interrupt is controlled by the action of the external interrupt pins, while the internal interrupts are controlled by the timer/event counter overflow, a usb interrupt and spi data transmission or reception. interrupt registers overall interrupt control, which means interrupt enabling and request flag setting, is controlled by the two inter - rupt control registers, which are located in the data memory. by controlling the appropriate enable bits in these registers each individual interrupt can be enabled or disabled. also when an interrupt occurs, the corre - sponding request flag will be set by the microcontroller. the global enable flag if cleared to zero will disable all interrupts. interrupt operation a usb interrupt, timer/event counter overflow, 8-bits of data transmission or reception on either of the one spi interfaces or an active edge on the external interrupt pin will all generate an interrupt request by setting their corresponding request flag, if their appropriate interrupt enable bit is set. when this happens, the program counter, which stores the address of the next instruction to be executed, will be transferred onto the stack. the program counter will then be loaded with a new ad - dress which will be the value of the corresponding inter - rupt vector. the microcontroller will then fetch its next instruction from this interrupt vector. the instruction at this vector will usually be a jmp statement which will jump to another section of program which is known as the interrupt service routine. here is located the code to control the appropriate interrupt. the interrupt service routine must be terminated with a reti statement, which retrieves the original program counter address from the stack and allows the microcontroller to continue with normal execution at the point where the interrupt occurred. the various interrupt enable bits, together with their as - sociated request flags, are shown in the accompanying diagram with their order of priority. once an interrupt subroutine is serviced, all the other in - terrupts will be blocked, as the emi bit will be cleared au - tomatically. this will prevent any further interrupt nesting from occurring. however, if other interrupt requests oc - cur during this interval, although the interrupt will not be immediately serviced, the request flag will still be re - corded. if an interrupt requires immediate servicing while the program is already in another interrupt service routine, the emi bit should be set after entering the rou - tine, to allow interrupt nesting. if the stack is full, the in - terrupt request will not be acknowledged, even if the related interrupt is enabled, until the stack pointer is decremented. if immediate service is desired, the stack must be prevented from becoming full.
ht82a520r/ht82a620r rev.1.30 23 january 14, 2011 i n t c 1 r e g i s t e r s p i s e r i a l i n t e r f a c e i n t e r r u p t e n a b l e 1 : e n a b l e 0 : d i s a b l e n o t i m p l e m e n t e d , r e a d a s " 0 " s p i s e r i a l i n t e r f a c e d a t a t r a n s f e r r e d o r d a t a r e c e i v e d i n t e r r u p t r e q u e s t f l a g 1 : a c t i v e 0 : i n a c t i v e n o t i m p l e m e n t e d , r e a d a s " 0 " b 7 b 0 e s i i s i f intc1 register i n t c 0 r e g i s t e r m a s t e r i n t e r r u p t g l o b a l e n a b l e 1 : g l o b a l e n a b l e 0 : g l o b a l d i s a b l e u s b i n t e r r u p t e n a b l e 1 : e n a b l e 0 : d i s a b l e e x t e r n a l i n t e r r u p t e n a b l e 1 : e n a b l e 0 : d i s a b l e t i m e r / e v e n t c o u n t e r i n t e r r u p t e n a b l e 1 : e n a b l e 0 : d i s a b l e u s b i n t e r r u p t r e q u e s t f l a g 1 : a c t i v e 0 : i n a c t i v e e x t e r n a l i n t e r r u p t r e q u e s t f l a g 1 : a c t i v e 0 : i n a c t i v e t i m e r / e v e n t c o u n t e r i n t e r r u p t r e q u e s t f l a g 1 : a c t i v e 0 : i n a c t i v e f o r t e s t m o d e u s e d o n l y m u s t b e w r i t t e n a s " 0 " ; o t h e r w i s e m a y r e s u l t i n u n p r e d i c t a b l e o p e r a t i o n b 7 b 0 e e i e u i e m i e i ft f e t i u s b f intc0 register
ht82a520r/ht82a620r rev.1.30 24 january 14, 2011 interrupt priority interrupts, occurring in the interval between the rising edges of two consecutive t2 pulses, will be serviced on the latter of the two t2 pulses, if the corresponding inter - rupts are enabled. in case of simultaneous requests, the following table shows the priority that is applied. these can be masked by resetting the emi bit. interrupt source priority vector usb interrupt 1 0004h external interrupt 2 0008h timer/event counter overflow interrupt 3 000ch spi interrupt 4 0010h suitable masking of the individual interrupts using the interrupt registers can prevent simultaneous occur - rences. external interrupt for an external interrupt to occur, the global interrupt en - able bit, emi, and external interrupt enable bit, eei, must first be set. an actual external interrupt will take place when the external interrupt request flag, eif is set, a situation that will occur when a high to low transition appears on the interrupt pins. the external interrupt pin is pin-shared with the i/o pins pa6 can only be config - ured as an external interrupt pin if the corresponding ex - ternal interrupt enable bits in the interrupt control register intc0 have been set. the pins must also be setup as inputs by setting the corresponding pac.6 bits in the port control register. when the interrupt is en- abled, the stack is not full and a high to low transition ap- pears on the external interrupt pin, a subroutine call to the external interrupt vector at location 08h will take place. when the interrupt is serviced, the external inter - rupt request flag, eif will be automatically reset and the emi bit will be automatically cleared to disable other in - terrupts. note that any pull-high resistor configuration options on these pins will remain valid even if the pins are used as external interrupt inputs. timer/event counter interrupt for a timer/event counter interrupt to occur, the global interrupt enable bit, emi, and the corresponding timer interrupt enable bit, eti, must first be set. an actual timer/event counter interrupt will take place when the timer/event counter interrupt request flag, tf, is set, a situation that will occur when the timer/event counter overflows. when the interrupt is enabled, the stack is not full and a timer/event counter overflow occurs, a subroutine call to the timer interrupt vector at location 0ch , will take place. when the interrupt is serviced, the timer interrupt request flag, tf, will be automatically re - set and the emi bit will be automatically cleared to dis - able other interrupts. spi interrupt for a spi interrupt to occur, the global interrupt enable bit, emi, and the corresponding spi interrupt enable bit, esii must be first set. an actual spi interrupt will take place when one of the two spi interrupt request flags, sif is set, a situation that will occur when 8-bits of data are transferred or received from either of the spi inter - faces. when the interrupt is enabled, the stack is not full and an spi interrupt occurs, a subroutine call to the spi interrupt vector at location 10h, will take place. when the interrupt is serviced, the spi interrupt request flag, sif will be automatically reset and the emi bit will be au - tomatically cleared to disable other interrupts. usb interrupt a usb interrupts will be triggered by the following usb events, at which point the the related interrupt request flag, usbf in the intc0 register, will be set. accessing the corresponding usb fifo from the pc a usb suspend signal from the pc a usb resume signal from the pc a usb reset signal when the interrupt is enabled, the stack is not full and the usb interrupt is active, a subroutine call to location 04h will occur. the interrupt request flag, usbf, and the emi bit will be cleared to disable other interrupts. when pc host accesses the fifo of the device, the corresponding request usr bit is set, and a usb inter- rupt is triggered. therefore it can be determined which fifo has been accessed. when the interrupt has been served, the corresponding bit should be cleared by the program. when the device receive a usb suspend sig- nal from the host pc, the suspend line, bit0 of usc, is set and a usb interrupt is also triggered. also when de - vice receive a resume signal from the host pc, the re - sume line, bit3 of usc, is set and a usb interrupt is triggered. programming considerations by disabling the interrupt enable bits, a requested inter - rupt can be prevented from being serviced, however, once an interrupt request flag is set, it will remain in this condition in the interrupt control register until the corre - sponding interrupt is serviced or until the request flag is cleared by a software instruction. it is recommended that programs do not use the 2call subroutine2 instruction within the interrupt subroutine. interrupts often occur in an unpredictable manner or need to be serviced immediately in some applications. if only one stack is left and the interrupt is not well con - trolled, the original control sequence will be damaged once a 2 call subroutine2 is executed in the interrupt subroutine. all of these interrupts have the capability of waking up the processor when in the power down mode.
ht82a520r/ht82a620r rev.1.30 25 january 14, 2011 only the program counter is pushed onto the stack. if the contents of the accumulator or status register are al - tered by the interrupt service program, which may cor - rupt the desired control sequence, then the contents should be saved in advance. reset and initialisation a reset function is a fundamental part of any microcontroller ensuring that the device can be set to some predetermined condition irrespective of outside parameters. the most important reset condition is after power is first applied to the microcontroller. in this case, internal circuitry will ensure that the microcontroller, af - ter a short delay, will be in a well defined state and ready to execute the first program instruction. after this power-on reset, certain important internal registers will be set to defined states before the program com - mences. one of these registers is the program counter, which will be reset to zero forcing the microcontroller to begin program execution from the lowest program memory address. in addition to the power-on reset, situations may arise where it is necessary to forcefully apply a reset condition when the microcontroller is running. one example of this is where after power has been applied and the microcontroller is already running, the res line is force - fully pulled low. in such a case, known as a normal oper - ation reset, some of the microcontroller registers remain unchanged allowing the microcontroller to proceed with normal operation after the reset line is allowed to return high. another type of reset is when the watchdog timer overflows and resets the microcontroller. all types of re- set operations result in different register conditions be- ing setup. another reset exists in the form of a low voltage reset, lvr, where a full reset, similar to the res reset is imple - mented in situations where the power supply voltage falls below a certain threshold. reset functions there are five ways in which a microcontroller reset can occur, through events occurring both internally and ex - ternally: power-on reset the most fundamental and unavoidable reset is the one that occurs after power is first applied to the microcontroller. as well as ensuring that the program memory begins execution from the first memory ad - dress, a power-on reset also ensures that certain other registers are preset to known conditions. all the i/o port and port control registers will power up in a high condition ensuring that all pins will be first set to inputs. although the microcontroller has an internal rc reset function, if the vdd power supply rise time is not fast enough or does not stabilise quickly at power-on, the internal reset function may be incapable of providing a proper reset operation. in such cases it is recom - mended that an external rc network is connected to the res pin, whose additional time delay will ensure that the res pin remains low for an extended period to allow the power supply to stabilise. during this time delay, normal operation of the microcontroller will be inhibited. after the res line reaches a certain voltage value, the reset delay time t rstd is invoked to provide an extra delay time after which the microcontroller will begin normal operation. the abbreviation sst in the figures stands for system start-up timer. for most applications a resistor connected between vdd and the res pin and a capacitor connected be - tween vss and the res pin will provide a suitable ex - ternal reset circuit. any wiring connected to the res pin should be kept as short as possible to minimise any stray noise interference. for applications that operate within an environment where more noise is present the enhanced reset cir - cuit shown is recommended. more information regarding external reset circuits is located in application note ha0075e on the holtek website. r e s v d d s s t t i m e - o u t i n t e r n a l r e s e t 0 . 9 v d d t r s t d power-on reset timing chart r e s v d d v s s 0 . 1 m f 1 0 0 k w basic reset circuit r e s 0 . 1 m f 1 0 0 k w v d d v s s 0 . 0 1 m f 1 0 k w enhanced reset circuit
ht82a520r/ht82a620r rev.1.30 26 january 14, 2011 res pin reset this type of reset occurs when the microcontroller is already running and the res pin is forcefully pulled low by external hardware such as an external switch. in this case as in the case of other reset, the program counter will reset to zero and program execution initi - ated from this point. note that as the external reset pin is also pin-shared with pa7, if it is to be used as a reset pin, the correct reset configuration option must be se - lected. low voltage reset - lvr the microcontroller contains a low voltage reset cir - cuit in order to monitor the supply voltage of the de - vice. the lvr function is selected via a configuration option. if the supply voltage of the device drops to within a range of 0.9v~v lvr such as might occur when changing the battery, the lvr will automatically reset the device internally. for a valid lvr signal, a low sup - ply voltage, i.e., a voltage in the range between 0.9v~v lvr must exist for a time greater than that spec - ified by t lvr in the a.c. characteristics. if the low sup - ply voltage state does not exceed this value, the lvr will ignore the low supply voltage and will not perform a reset function. the actual v lvr value can be se - lected via configuration options. watchdog time-out reset during normal operation the watchdog time-out reset during normal opera - tion is the same as a hardware res pin reset except that the watchdog time-out flag to will be set to 212. watchdog time-out reset during power down the watchdog time-out reset during power down is a little different from other kinds of reset. most of the conditions remain unchanged except that the pro - gram counter and the stack pointer will be cleared to 202 and the to flag will be set to 212 . refer to the a.c. characteristics for t sst details. reset initial conditions the different types of reset described affect the reset flags in different ways. these flags, known as pdf and to are located in the status register and are controlled by various microcontroller operations, such as the power down function or watchdog timer. the reset flags are shown in the table: to pdf reset conditions 0 0 res reset during power-on 0 0 res wake-up during power down 0 0 res or lvr reset during normal operation 1 u wdt time-out reset during normal operation 1 1 wdt time-out reset during power down note: 2u2 stands for unchanged the following table indicates the way in which the vari- ous components of the microcontroller are affected after a power-on reset occurs. item condition after reset program counter reset to zero interrupts all interrupts will be disabled wdt clear after reset, wdt begins counting timer/event counter timer counter will be turned off prescaler the timer counter prescaler will be cleared input/output ports i/o ports will be setup as inputs stack pointer stack pointer will point to the top of the stack r e s s s t t i m e - o u t i n t e r n a l r e s e t 0 . 9 v d d 0 . 4 v d d t r s t d res reset timing chart l v r s s t t i m e - o u t i n t e r n a l r e s e t t r s t d low voltage reset timing chart w d t t i m e - o u t s s t t i m e - o u t i n t e r n a l r e s e t t r s t d wdt time-out reset during normal operation timing chart w d t t i m e - o u t s s t t i m e - o u t t s s t wdt time-out reset during power down timing chart
ht82a520r/ht82a620r rev.1.30 27 january 14, 2011 the different kinds of resets all affect the internal registers of the microcontroller in different ways. to ensure reliable continuation of normal program execution after a reset occurs, it is important to know what condition the microcontroller is in after a particular reset occurs. the following table describes how each type of reset affects the microcontroller in - ternal registers. register reset (power-on) wdt time-out (normal operation) res reset (normal operation) res reset (halt) wdt time-out (halt)* usb reset (normal) usb reset (halt) mp0 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu xxxx xxxx xxxx xxxx mp1 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu xxxx xxxx xxxx xxxx acc xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu pcl 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 tblp xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu tblh xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu wdts ---- -111 ---- -111 ---- -111 ---- -111 ---- -111 ---- -111 ---- -uuu status --00 xxxx --1u uuuu --00 uuuu --00 uuuu --11 uuuu --uu uuuu --01 uuuu intc0 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu 0000 0000 0000 0000 tmrh xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu xxxx xxxx xxxx xxxx tmrl xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu xxxx xxxx xxxx xxxx tmrc 00-0 1--- 00-0 1--- 00-0 1--- 00-0 1--- uu-u u--- uu-u u--- uu-u u--- pa 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111 pac 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111 pb 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111 pbc 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111 pc 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111 pcc 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111 pwm0drl 0000 --00 0000 --00 0000 --00 0000 --00 uuuu --uu 0000 --00 0000 --00 pwm0drh 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu 0000 0000 0000 0000 pwmbr0 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu 0000 0000 0000 0000 pwm1drl 0000 --00 0000 --00 0000 --00 0000 --00 uuuu --uu 0000 --00 0000 --00 pwm1drh 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu 0000 0000 0000 0000 pwmbr1 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu 0000 0000 0000 0000 pwm2drl 0000 --00 0000 --00 0000 --00 0000 --00 uuuu --uu 0000 --00 0000 --00 pwm2drh 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu 0000 0000 0000 0000 pwmbr2 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu 0000 0000 0000 0000 adrl(**) xxxx ---- xxxx ---- xxxx ---- xxxx ---- xxxx ---- xxxx ---- uuuu ---- adrh(**) xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu adcr(**) 0100 0000 0100 0000 0100 0000 0100 0000 0100 0000 0100 0000 0100 0000 acsr(**) 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu 0000 0000 0000 0000 usb_stat --xx 0000 --xx 0000 --xx 0000 --xx 0000 --xx 0000 --xx 0000 --xx 0000 uint 0000 1111 0000 uuuu 0000 1111 0000 1111 0000 uuuu 0000 1111 0000 1111 tbhp xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu usc 1000 0000 uuuu xuux 1000 x00x 1000 x00x uuuu xuux 1000 0000 1000 0000 usr 0000 0000 uuuu uuuu 0000 0000 0000 0000 uuuu uuuu 00uu 0000 00uu 0000
ht82a520r/ht82a620r rev.1.30 28 january 14, 2011 register reset (power-on) wdt time-out (normal operation) res reset (normal operation) res reset (halt) wdt time-out (halt)* usb reset (normal) usb reset (halt) ucc 0000 0000 uuuu uuuu 0000 0000 0000 0000 uuuu uuuu 0uu0 u000 0uu0 u000 awr 0000 0000 uuuu uuuu 0000 0000 0000 0000 uuuu uuuu 0000 0000 0000 0000 stall 0000 0000 uuuu uuuu 0000 0000 0000 0000 uuuu uuuu 0000 0000 0000 0000 sies 0000 0000 uuxx xxuu 0000 0000 0000 0000 uuxx xxuu 0u00 u000 0u00 u000 misc 0000 0000 xxuu uuuu 0000 0000 0000 0000 xxuu uuuu 0000 0000 0000 0000 ufien 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu uuuu uuuu uuuu uuuu fifo0 xxxx xxxx 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 fifo1 xxxx xxxx 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 fifo2 xxxx xxxx 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 fifo3 xxxx xxxx 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ufoen 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu uuuu uuuu uuuu uuuu ufc0 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu uuuu uuuu uuuu uuuu ufc1 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu uuuu uuuu uuuu uuuu usvc 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu 0000 0000 0000 0000 sbcr 0110 0000 0110 0000 0110 0000 0110 0000 0110 0000 uuuu uuuu uuuu uuuu sbdr xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu spir ---- 0000 ---- 0000 ---- 0000 ---- 0000 ---- 0000 ---- 0000 ---- 0000 note: 2*2 means 2warm reset2, 2-2 not implemented 2u2 means 2unchanged2, 2x2 means 2unknown2 2**2 for ht82a620r
ht82a520r/ht82a620r rev.1.30 29 january 14, 2011 oscillator a crystal across osc1 and osc2 is needed to provide the feedback and phase shift required for the oscillator. no other external components are required. the ht82a520r/ht82a620r can operate with 6mhz or 12mhz system clocks. in order to make sure that the usbsie functions properly, the user should correctly configure the sysclk bit of the ucc register. the de - fault system clock is 12mhz power down mode and wake-up power down mode all of the holtek microcontrollers have the ability to enter a power down mode. when the device enters this mode, the normal operating current, will be reduced to an extremely low standby current level. this occurs be - cause when the device enters the power down mode, the system oscillator is stopped which reduces the power consumption to extremely low levels, however, as the device maintains its present internal condition, it can be woken up at a later stage and continue running, without requiring a full reset. this feature is extremely important in application areas where the microcontroller must have its power supply constantly maintained to keep the device in a known condition but where the power supply capacity is limited such as in battery appli- cations. entering the power down mode there is only one way for the device to enter the power down mode and that is to execute the 2 halt2 instruc - tion in the application program. when this instruction is executed, the following will occur: the system oscillator will stop running and the appli - cation program will stop at the 2halt2 instruction. the data memory contents and registers will maintain their present condition. the wdt will be cleared and resume counting if the wdt clock source is selected to come from the wdt oscillator. the wdt will stop if its clock source origi - nates from the system clock. the i/o ports will maintain their present condition. in the status register, the power down flag, pdf, will be set and the watchdog time-out flag, to, will be cleared. standby current considerations as the main reason for entering the power down mode is to keep the current consumption of the microcontroller to as low a value as possible, perhaps only in the order of several micro-amps, there are other considerations which must also be taken into account by the circuit de - signer if the power consumption is to be minimised. special attention must be made to the i/o pins on the device. all high-impedance input pins must be con - nected to either a fixed high or low level as any floating input pins could create internal oscillations and result in increased current consumption. care must also be taken with the loads, which are connected to i/o pins, which are setup as outputs. these should be placed in a condition in which minimum current is drawn or con - nected only to external circuits that do not draw current, such as other cmos inputs. if the configuration options have enabled the watchdog timer internal oscillator then this will continue to run when in the power down mode and will thus consume some power. for power sensitive applications it may be therefore preferable to use the system clock source for the watchdog timer. if any i/o pins are configured as a/d analog inputs using the channel configuration bits in the adcr register, then the a/d converter will be turned on and a certain amount of power will be consumed. it may be therefore desirable before entering te power down mode to ensure that the a/d converter is powered down by ensuring that any a/d input pins are setup as normal logic inputs with pull-high resistors.note: a/d function for ht82a620r. wake-up after the system enters the power down mode, it can be woken up from one of various sources listed as follows: an external reset an external falling edge on any of the i/o pins a system interrupt a wdt overflow if the system is woken up by an external reset, the de - vice will experience a full system reset, however, if the device is woken up by a wdt overflow, a watchdog timer reset will be initiated. although both of these wake-up methods will initiate a reset operation, the ac - tual source of the wake-up can be determined by exam - ining the to and pdf flags. the pdf flag is cleared by a system power-up or executing the clear watchdog timer instructions and is set when executing the 2 halt2 instruction. the to flag is set if a wdt time-out occurs, and causes a wake-up that only resets the program counter and stack pointer, the other flags remain in their original status. o s c 2 o s c 1 crystal oscillator
ht82a520r/ht82a620r rev.1.30 30 january 14, 2011 each pins on port a or any nibble on the other ports can be setup via an individual configuration option to permit a negative transition on the pin to wake-up the system. when a port pins wake-up occurs, the program will re - sume execution at the instruction following the 2 halt2 in - struction. if the system is woken up by an interrupt, then two possi - ble situations may occur. the first is where the related in - terrupt is disabled or the interrupt is enabled but the stack is full, in which case the program will resume execution at the instruction following the 2 halt2 instruction. in this sit - uation, the interrupt which woke-up the device will not be immediately serviced, but will rather be serviced later when the related interrupt is finally enabled or when a stack level becomes free. the other situation is where the related interrupt is enabled and the stack is not full, in which case the regular interrupt response takes place. if an interrupt request flag is set to 212 before entering the power down mode, the wake-up function of the related in - terrupt will be disabled. no matter what the source of the wake-up event is, once a wake-up situation occurs, a time period equal to 1024 sys - tem clock periods will be required before normal system operation resumes. however, if the wake-up has origi - nated due to an interrupt, the actual interrupt subroutine execution will be delayed by an additional one or more cy - cles. if the wake-up results in the execution of the next in - struction following the 2 halt2 instruction, this will be executed immediately after the 1024 system clock period delay has ended. watchdog timer the watchdog timer is provided to prevent program mal - functions or sequences from jumping to unknown loca - tions, due to certain uncontrollable external events such as electrical noise. it operates by providing a device reset when the wdt counter overflows. the wdt clock is sup - plied by one of two sources selected by configuration op - tion: its own self-contained dedicated internal wdt oscillator, or the instruction clock which is the system clock divided by 4. note that if the wdt configuration option has been disabled, then any instruction relating to its opera - tion will result in no operation. the internal wdt oscillator has an approximate period of 31m s at a supply voltage of 5v. if selected, it is first divided by 256 via an 8-stage counter to give a nominal period of 8ms. note that this period can vary with vdd, temperature and process variations. for longer wdt time-out periods the wdt prescaler can be utilized. by writing the required value to bits 0, 1 and 2 of the wdts register, known as ws0, ws1 and ws2, longer time-out periods can be achieved. with ws0, ws1 and ws2 all equal to 1, the di - vision ratio is 1:128 which gives a maximum time-out pe - riod of about 1s. a configuration option can select the instruction clock, which is the system clock divided by 4, as the wdt clock source instead of the internal wdt oscillator. if the instruc - tion clock is used as the clock source, it must be noted that when the system enters the power down mode, as the system clock is stopped, then the wdt clock source will also be stopped. therefore the wdt will lose its protecting 8 - b i t c o u n t e r ( ? 2 5 6 ) 7 - b i t p r e s c a l e r 8 - t o - 1 m u x w d t t i m e - o u t w s 0 ~ w s 2 w d t c l o c k s o u r c e c l e a r w d t t y p e c o n f i g u r a t i o n o p t i o n c l r w d t 1 f l a g c l r w d t 2 f l a g 1 o r 2 i n s t r u c t i o n s c l r c l r f s y s / 4 w d t o s c i l l a t o r w d t c l o c k s o u r c e c o n f i g u r a t i o n o p t i o n watchdog timer w s 2 w d t s r e g i s t e r b 7 b 0 w d t p r e s c a l e r r a t e s e l e c t w s 2 0 0 0 0 1 1 1 1 w s 1 0 0 1 1 0 0 1 1 w s 0 0 1 0 1 0 1 0 1 w d t r a t e 1 : 1 1 : 2 1 : 4 1 : 8 1 : 1 6 1 : 3 2 1 : 6 4 1 : 1 2 8 n o t u s e d w s 1 w s 0 watchdog timer register
ht82a520r/ht82a620r rev.1.30 31 january 14, 2011 purposes. in such cases the system cannot be restarted by the wdt and can only be restarted using external signals. for systems that operate in noisy environ - ments, using the internal wdt oscillator is therefore the recommended choice. under normal program operation, a wdt time-out will in - itialise a device reset and set the status bit to. however, if the system is in the power down mode, when a wdt time-out occurs, only the program counter and stack pointer will be reset. three methods can be adopted to clear the contents of the wdt and the wdt prescaler. the first is an external hardware reset, which means a low level on the res pin, the second is using the watch - dog software instructions and the third is via a 2 halt 2 in - struction. there are two methods of using software instructions to clear the watchdog timer, one of which must be chosen by configuration option. the first option is to use the sin - gle 2 clr wdt2 instruction while the second is to use the two commands 2 clr wdt12 and 2 clr wdt22 . for the first option, a simple execution of 2 clr wdt2 will clear the wdt while for the second option, both 2clr wdt12 and 2 clr wdt22 must both be executed to successfully clear the wdt. note that for this second option, if 2 clr wdt12 is used to clear the wdt, succes - sive executions of this instruction will have no effect, only the execution of a 2 clr wdt22 instruction will clear the wdt. similarly, after the 2 clr wdt22 instruc- tion has been executed, only a successive 2 clr wdt12 instruction can clear the watchdog timer. pulse width modulator the device contains three pulse width modulation pwm outputs. useful for such applications such as mo - tor speed control, the pwm function provides an output with a variable frequency, and with a duty cycle that can be varied by setting particular values into the corre - sponding register pair. channel pwm mode output pin register names 1 8+4 pa4 pwm0drl~ pwm0drh 2 8+4 pa5 pwm1drl~ pwm1drh 3 8+4 pb0 pwm2drl~ pwm2drh pwm registers three register, located in the data memory are assigned to each pulse width modulator output and are known as the pwm registers. it is in each register pair that the 12-bit value, which represents the overall duty cycle of one modulation cycle of the output waveform, should be placed. the pwm registers also contain the enable/dis - able control bit for the pwm outputs. to increase the pwm modulation frequency, each modulation cycle is modulated into sixteen individual modulation sub-sections, known as the 8+4 mode. note that it is only necessary to write the required modulation value into the corresponding pwm register as the subdivision of the waveform into its sub-modulation cycles is imple - mented automatically within the microcontroller hard - ware. this method of dividing the original modulation cycle into a further 16 sub-cycles enables the generation of higher pwm frequencies, which allow a wider range of applications to be served. as long as the periods of the generated pwm pulses are less than the time constants of the load, the pwm output will be suitable as such long time constant loads will average out the pulses of the pwm output. the difference between what is known as the pwm cycle frequency and the pwm modulation fre - quency should be understood. as the pwm clock is defined by register pwmbr and the system clock f sys or f sys /4 (chosen via the pwm_s bit), and as the pwm value is 12-bits wide, the overall pwm cycle frequency ( f pwm ) as the following equation and the corresponding pwm modulation frequency for 8+4 mode is f pwm /256 . f pwm = 1 (1/f )x(pwmbrn 1) sys + , when pwm_s=0 f pwm = 1 (4/f )x(pwmbrn 1) sys + , when pwm_s=1 where pwmbrn=0~255 and f sys may be 6mhz, 12mhz , n=0~2 , according register whether it is pwm0, pwm1 or pwm2 pwm modulation frequency pwm cycle frequency pwm cycle duty f pwm /256 f pwm /4096 (pwm register value)/4096
ht82a520r/ht82a620r rev.1.30 32 january 14, 2011 8+4 pwm mode modulation each full pwm cycle, as it is 12-bits wide, has 4096 clock periods. however, in the 8+4 pwm mode, each pwm cy - cle is subdivided into sixteen individual sub-cycles known as modulation cycle 0 ~ modulation cycle 15, denoted as 2 i 2 in the table. each one of these sixteen sub-cycles con - tains 256 clock cycles. in this mode, a modulation fre - quency increase of sixteen is achieved. the 12-bit pwm register value, which represents the overall duty cycle of the pwm waveform, is divided into two groups. the first group which consists of bit4~bit11 is denoted here as the dc value. the second group which consists of bit0~bit3 is known as the ac value. in the 8+4 pwm mode, the duty cycle value of each of the two modulation sub-cycles is shown in the following table. parameter ac (0~15) dc (duty cycle) modulation cycle i (i=0~15) i ht82a520r/ht82a620r rev.1.30 33 january 14, 2011 p w m r e g i s t e r s b 7 p w m o n / o f f c o n t r o l 1 : p w m e n a b l e 0 : i / o p i n e n a b l e p w m n b a s e p e r i o d r e g i s t e r f r e q u e n c y s o u r c e 1 : f s y s / 4 0 : f s y s ( d e f a u l t ) n o t i m p l e m e n t e d , r e a d a s " 0 " p w m a c v a l u e b i t s 0 ~ 3 p w m d c v a l u e b i t s 4 ~ 1 1 b 0 p w m _ e n 0 3 12 b 7 b 0 8 1 1 91 0 7 6 5 4 p w m 0 d r l ~ p w m 2 d r l l o w b y t e r e g i s t e r s p w m 0 d r h ~ p w m 2 d r h h i g h b y t e r e g i s t e r s p w m _ s pwm register pairs f p w m p w m [ p w m ] = 1 6 0 0 [ p w m ] = 1 6 0 1 p w m [ p w m ] = 1 6 0 2 p w m [ p w m ] = 1 6 1 5 p w m p w m c y c l e : 4 0 9 6 / 1 0 0 / 2 5 6 1 0 1 / 2 5 6 1 0 1 / 2 5 6 1 0 1 / 2 5 6 m o d u l a t i o n c y c l e 0 p w m m o d u l a t i o n p e r i o d : 2 5 6 / f s y s m o d u l a t i o n c y c l e 1 m o d u l a t i o n c y c l e 2 m o d u l a t i o n c y c l e 1 5 m o d u l a t i o n c y c l e 0 1 0 0 / 2 5 6 1 0 0 / 2 5 6 1 0 0 / 2 5 6 1 0 1 / 2 5 6 1 0 0 / 2 5 6 1 0 1 / 2 5 6 1 0 1 / 2 5 6 1 0 0 / 2 5 6 1 0 0 / 2 5 6 1 0 0 / 2 5 6 1 0 0 / 2 5 6 1 0 0 / 2 5 6 1 0 0 / 2 5 6 1 0 1 / 2 5 6 1 0 1 / 2 5 6 1 0 1 / 2 5 6 f p w m 8+4 pwm mode bit r/w description 7~0 r/w used to define the base period of the pwm range =1 ~ 256 (1/f sys or 4/f sys chosen via the pwm_s bit) where pwmbrn=0~255 (n= 0~2) pwm base period register pwmbr0 ~ pwmbr2
ht82a520r/ht82a620r rev.1.30 34 january 14, 2011 analog to digital converter - ht82a620r the need to interface to real world analog signals is a common requirement for many electronic systems. however, to properly process these signals by a microcontroller, they must first be converted into digital signals by a/d converters. by integrating the a/d con - version electronic circuitry into the microcontroller, the need for external components is reduced significantly with the corresponding follow-on benefits of lower costs and reduced component space requirements. a/d overview the device contains a multi-channel channel analog to digital converter which can directly interface to external analog signals, such as that from sensors or other con - trol signals and convert these signals directly into an 12-bit digital value. the number of available channels depends upon which package type is chosen. the a/d block diagram shows the overall internal struc - ture of the a/d converter, together with its associated registers. a/d converter data registers - adrl, adrh the device, which contain a single12-bit a/d converter, requires two data registers, known as adrl and adrh. after the conversion process takes place, these regis - ters can be directly read by the microcontroller to obtain the digitised conversion value. in the following tables, d0~d7 are the a/d conversion data result bits. register bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adrl d3 d2 d1 d0 ? ? ? ? adrh d11 d10 d9 d8 d7 d6 d5 d4 note: d11~d0 is the a/d conversion result data bit msb~lsb. a/d data register a/d converter control register - adcr to control the function and operation of the a/d con - verter, control registers known as adcr and adsr are provided. these 8-bit registers define functions such as the selection of which analog channel is connected to the internal a/d converter, which pins are used as ana - log inputs and which are used as normal i/os as well as controlling the start function and monitoring the a/d con - verter end of conversion status. one section of this register contains the bits acs3~acs0 which define the channel number. as each of the devices contains only one actual analog to digital converter circuit, each of the individual analog inputs must be routed to the converter. it is the function of the acs3~acs0 bits in the adcr register to determine which analog channel is actually connected to the inter - nal a/d converter. the start bit in the adcr register is used to start and reset the a/d converter. when the microcontroller sets this bit from low to high and then low again, an analog to digital conversion cycle will be initiated. when the start bit is brought from low to high but not low again, the eocb bit in the adcr register will be set to a 212 and the analog to digital converter will be reset. it is the start bit that is used to control the overall on/off opera - tion of the internal analog to digital converter. the eocb bit in the adcr register is used to indicate when the analog to digital conversion process is com- plete. this bit will be automatically set to 202 by the microcontroller after a conversion cycle has ended. in addition, the corresponding a/d interrupt request flag will be set in the interrupt control register, and if the inter- rupts are enabled, an appropriate internal interrupt sig - nal will be generated. this a/d internal interrupt signal will direct the program flow to the associated a/d inter - nal interrupt address for processing. if the a/d internal interrupt is disabled, the microcontroller can be used to a d c s o u r c e f s y s / 3 , f s y s / 6 , f s y s / 8 , f s y s / 1 6 ? n a c s r r e g i s t e r a d c v r e f a / d r e f e r e n c e v o l t a g e a d r l a / d d a t a r e g i s t e r s p c r 0 ~ p c r 3 a d c s 0 ~ a d c s 3 s t a r t e o c b a d c r r e g i s t e r p i n c o n f i g u r a t i o n b i t s c h a n n e l s e l e c t b i t s s t a r t b i t c l o c k d i v i d e r a t i o e n d o f c o n v e r s i o n b i t p c 0 / a n 8 ~ p c 7 / a n 1 5 p b 0 / a n 0 ~ p b 7 / a n 7 a d r h a d s r r e g i s t e r a/d converter structure
ht82a520r/ht82a620r rev.1.30 35 january 14, 2011 poll the eocb bit in the adcr register to check whether it has been cleared as an alternative method of detect - ing the end of an a/d conversion cycle. a/d converter clock source register - acsr the clock source for the a/d converter, which originates from the system clock f sys , is first divided by a division ratio, the value of which is determined by the adcs1 and adcs0 bits in the acsr register. the acsr control register also contains the pcr3~pcr0 bits which determine which pins on port b and port c are used as analog inputs for the a/d con- verter and which pins are to be used as normal i/o pins. if the 4-bit address on pcr3~pcr0 has a value of 2 1111 2 or higher, then all 16 pins, namely an0~ an15 will all be set as analog inputs. note that if the pcr3~pcr0 bits are all set to zero, then all the port b and port c pins will be setup as normal i/os and the internal a/d con - verter circuitry will be powered off to reduce the power consumption. although the a/d clock source is determined by the sys - tem clock f sys , and by bits adcs1 and adcs0, there are s ome limitations on the maximum a/d clock source speed that can be selected. as the minimum value of permissible a/d clock period, t ad , is 0.5 m s , care must be taken for sys- tem clock speeds in excess of 4mhz. for system clock speeds in excess of 4mhz, the adcs1 and adcs0 bits should not be set to 2 00 2 . doing so will give a/d clock peri- a d c r r e g i s t e r s e l e c t a / d c h a n n e l b 7 b 0 s t a r t a c s 2 a c s 1 a c s 0 a c s 1 0 0 1 1 : : 1 a c s 2 0 0 0 0 : : 1 a c s 0 0 1 0 1 : : 1 : a n 0 : a n 1 : a n 2 : a n 3 : : : a n 1 5 e n d o f a / d c o n v e r s i o n f l a g 1 : n o t e n d o f a / d c o n v e r s i o n - a / d c o n v e r s i o n w a i t i n g o r i n p r o g r e s s 0 : e n d o f a / d c o n v e r s i o n - a / d c o n v e r s i o n e n d e d s t a r t t h e a / d c o n v e r s i o n 0 ? 1 ? 0 : s t a r t 0 ? 1 : r e s e t a / d c o n v e r t e r a n d s e t e o c b t o " 1 " e o c b a c s 3 a c s 3 0 0 0 0 : : 1 n o t i m p l e m e n t e d , r e a d a s " 0 " a/d converter control register a c s r r e g i s t e r s e l e c t a / d c o n v e r t e r c l o c k s o u r c e b 7 b 0 t e s t a d c s 1 a d c s 0 a d c s 1 0 0 1 1 a d c s 0 0 1 0 1 : s y s t e m c l o c k / 3 : s y s t e m c l o c k / 6 : s y s t e m c l o c k / 8 : s y s t e m c l o c k / 1 6 p b a n d p c a / d c h a n n e l c o n f i g u r a t i o n f o r t e s t m o d e u s e o n l y p c r 3 p c r 2 p c r 1 p c r 0 p c r 3 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 p c r 2 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 : p b a n d p c a / d c h a n n e l - a l l o f f : p b 0 a s a n 0 : p b 0 ~ p b 1 a s a n 0 ~ a n 1 : p b 0 ~ p b 2 a s a n 0 ~ a n 2 : p b 0 ~ p b 3 a s a n 0 ~ a n 3 : p b 0 ~ p b 4 a s a n 0 ~ a n 4 : p b 0 ~ p b 5 a s a n 0 ~ a n 5 : p b 0 ~ p b 6 a s a n 0 ~ a n 6 : p b 0 ~ p b 7 a s a n 0 ~ a n 7 : p b 0 ~ p b 7 , p c 0 a s a n 0 ~ a n 8 : p b 0 ~ p b 7 , p c 0 ~ p c 1 a s a n 0 ~ a n 9 : p b 0 ~ p b 7 , p c 0 ~ p c 2 a s a n 0 ~ a n 1 0 : p b 0 ~ p b 7 , p c 0 ~ p c 3 a s a n 0 ~ a n 1 1 : p b 0 ~ p b 7 , p c 0 ~ p c 4 a s a n 0 ~ a n 1 2 : p b 0 ~ p b 7 , p c 0 ~ p c 5 a s a n 0 ~ a n 1 3 : p b 0 ~ p b 7 , p c 0 ~ p c 7 a s a n 0 ~ a n 1 5 p c r 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 p c r 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 : d i s a b l e ( d e f a u l t ) 1 : e n a b l e a d o n a/d converter clock source register
ht82a520r/ht82a620r rev.1.30 36 january 14, 2011 ods that are less than the minimum a/d clock period which may result in inaccurate a/d conversion values. refer to the following table for examples, where values marked with an asterisk * show where, depending upon the de - vice, special care must be taken, as the values may be less than the specified minimum a/d clock period a/d input pins all of the a/d analog input pins are pin-shared with the i/o pins on port b and port c. bits pcr3~pcr0 in the acsr register, determine whether the input pins are setup as normal port b and port c input/output pins or whether they are setup as analog inputs. in this way, pins can be changed under program control to change their function from normal i/o operation to analog inputs and vice versa. pull-high resistors, which are setup through configuration options, apply to the input pins only when they are used as normal i/o pins, if setup as a/d inputs the pull-high resistors will be automatically disconnected. note that it is not necessary to first setup the a/d pin as an input in the pbc or pcc port control register to enable the a/d input as when the pcr3~pcr0 bits enable an a/d input, the status of the port control register will be overridden. initialising the a/d converter the internal a/d converter must be initialised in a spe - cial way. each time the port b and port c a/d channel selection bits are modified by the program, the a/d con- verter must be re-initialised. if the a/d converter is not initialised after the channel selection bits are changed, the eocb flag may have an undefined value, which may produce a false end of conversion signal. to initialise the a/d converter after the channel selection bits have changed, then, within a time frame of one to ten instruc- tion cycles, the start bit in the adcr register must first be set high and then immediately cleared to zero. this will ensure that the eocb flag is correctly set to a high condition. summary of a/d conversion steps the following summarises the individual steps that should be executed in order to implement an a/d con - version process. step 1 select the required a/d conversion clock by correctly programming bits adcs1 and adcs0 in the acsr register. step 2 select which channel is to be connected to the internal a/d converter by correctly programming the acs3~ acs0 bits which are also contained in the adcr register. step 3 select which pins on port b and port c are to be used as a/d inputs and configure them as a/d input pins by correctly programming the pcr3~pcr0 bits in the acsr register. step 4 the analog to digital conversion process can now be initialised by setting the start bit in the adcr regis - ter from 202 to 212 and then to 202 again. note that this bit should have been originally set to 202. step 5 to check when the analog to digital conversion pro- cess is complete, the eocb bit in the adcr register can be polled. the conversion process is complete when this bit goes low. when this occurs the a/d data registers adr can be read to obtain the conversion value. as an alternative method if the interrupts are enabled and the stack is not full, the program can wait for an a/d interrupt to occur. 0 0 0 b 0 0 0 b 0 1 1 b 0 1 0 b s t a r t e o c b p c r 3 ~ p c r 0 a c s 3 ~ a c s 0 p o w e r - o n r e s e t e n d o f a / d c o n v e r s i o n 1 : d e f i n e p b , p c c o n f i g u r a t i o n 2 : s e l e c t a n a l o g c h a n n e l s t a r t o f a / d c o n v e r s i o n r e s e t a / d c o n v e r t e r 0 0 0 b s t a r t o f a / d c o n v e r s i o n r e s e t a / d c o n v e r t e r 0 0 0 b 1 . p o r t b a n d p o r t c s e t u p a s i / o s 2 . a / d c o n v e r t e r i s p o w e r e d o f f t o r e d u c e p o w e r c o n s u m p t i o n 1 0 0 b 0 0 1 b s t a r t o f a / d c o n v e r s i o n r e s e t a / d c o n v e r t e r d o n ' t c a r e e n d o f a / d c o n v e r s i o n e n d o f a / d c o n v e r s i o n s t a r t b i t s e t h i g h w i t h i n o n e t o t e n i n s t r u c t i o n c y c l e s a f t e r t h e p c r 0 ~ p c r 2 b i t s c h a n g e s t a t e a / d c l o c k m u s t b e f s y s / 3 , f s y s / 6 , f s y s / 8 , f s y s / 1 6 n o t e : a / d s a m p l i n g t i m e a / d s a m p l i n g t i m e a / d s a m p l i n g t i m e 8 t a d 8 t a d 8 t a d t a d c a / d c o n v e r s i o n t i m e a / d c o n v e r s i o n t i m e a / d c o n v e r s i o n t i m e t a d c t a d c a/d conversion timing
ht82a520r/ht82a620r rev.1.30 37 january 14, 2011 note: when checking for the end of the conversion pro - cess, if the method of polling the eocb bit in the adcr register is used, the interrupt enable step above can be omitted. the a/d conversion timing diagram shows graphically the various stages involved in an analog to digital conversion process and its associated timing. the setting up and operation of the a/d converter function is fully under the control of the application program as there are no configuration options associated with the a/d converter. after an a/d conversion process has been initi - ated by the application program, the microcontroller inter - nal hardware will begin to carry out the conversion, during which time the program can continue with other functions. the time taken for the a/d conversion is 16t ad where t ad is e qual to the a/d clock period. programming considerations when programming, special attention must be given to the a/d channel selection bits in the adsr register. if these bits are all cleared to zero no external pins will be selected for use as a/d input pins allowing the pins to be used as normal i/o pins. when this happens the power supplied to the internal a/d circuitry will be reduced result - ing in a reduction of supply current. this ability to reduce power by turning off the internal a/d function by clearing the a/d channel selection bits may be an important con - sideration in battery powered applications. another important programming consideration is that when the a/d channel selection bits change value, the a/d converter must be re-initialised. this is achieved by pulsing the start bit in the adcr register immediately after the channel selection bits have changed state. the exception to this is where the channel selection bits are all cleared, in which case the a/d converter is not required to be re-initialised. a/d programming example the following two programming examples illustrate how to setup and implement an a/d conversion. in the first exam - ple, the method of polling the eocb bit in the adcr regis - ter is used to detect when the conversion cycle is complete, whereas in the second example, the a/d inter - rupt is used to determine when the conversion is com - plete. a/d transfer function as the device contain a 12-bit a/d converter, its full-scale converted digitised value is equal to fffh. since the full-scale analog input value is equal to the vdd voltage, this gives a single bit analog input value of v dd /4096. the diagram show the ideal transfer function between the ana - log input value and the digitised output value for the a/d converter. note that to reduce the quantisation error, a 2.5 lsb offset is added to the a/d converter input. except for the digit - ised zero value, the subsequent digitised values will change at a point 2.5 lsb below where they would change without the offset, and the last full scale digitised value will change at a point 2.5 lsb below the v dd level. example: using an eocb polling method to detect the end of conversion clr eadi ; disable adc interrupt mov a,00011001b mov acsr,a ; setup the acsr register to select fsys/6 as the a/d clock ; setup the acsr register to configure port pb0~pb2 as a/d ; inputs mov a,00000000b mov adcr,a ; setup the adcr register and select an0 to be connected to ; the a/d converter ; as the port b and port c channel bits have changed the ; following start signal (0 ?1? 0) must be issued within ; 10 instruction cycles set adon ; a/d on start_conversion: clr start set start ; reset a/d clr start ; start a/d polling_eoc: sz eocb ; poll the adcr register eocb bit to detect end ; of a/d conversion jmp polling_eoc ; continue polling mov a,adr ; read conversion result value mov adrl_buffer,a ; save result to user defined register : jmp start_conversion ; start next a/d conversion
ht82a520r/ht82a620r rev.1.30 38 january 14, 2011 spi serial interface the device includes one spi serial interfaces. the spi in - terface is a full duplex serial data link, originally designed by motorola, which allows multiple devices connected to the same spi bus to communicate with each other. the devices communicate using a master/slave technique where only the single master device can initiate a data transfer. a simple four line signal bus is used for all com - munication. spi interface communication four lines are used for each function. these are, sdi - serial data input, sdo - serial data output, sck - serial clock and scs - slave select. note that the condition of the slave select line is conditioned by the csen bit in the sbcr control register. if the csen bit is high then the scs line is active while if the bit is low then the scs line will be in a floating condition. the accompanying timing di - agram depicts the basic timing protocol of the spi bus. spi registers there are three registers for control of the spi interface. these are the sbcr register which is the control register and the sbdr which is the data register and spir register which is the spi mode control register. the sbcr register is used to setup the required setup parameters for the spi bus and also used to store associated operating flags, while the sbdr register is used for data storage. the spir register is used to select spi mode, clock polar - ity edge selection and spi enable or disable selection. after power on, the contents of the sbdr register will be in an unknown condition while the sbcr register will de - fault to the condition below: cks m1 m0 sben mls csen wcol trf 0 1 1 0 0 0 0 0 note that data written to the sbdr register will only be written to the txrx buffer, whereas data read from the sbdr register will actual be read from the register. spi bus enable/disable to enable the spi bus, the sben bit should be set high, then wait for data to be written to the sbdr (txrx buffer) register. for the master mode, after data has been written to the sbdr (txrx buffer) register then transmission or reception will start automatically. when all the data has been transferred, the trf bit should be set. for the slave mode, when clock pulses are received on sck, data in the txrx buffer will be shifted out or data on sdi will be shifted in. to disable the spi bus sck, sdi, sdo, scs should be i/o mode. f f e h ( ) a / d c o n v e r s i o n r e s u l t f f f h f f d h 0 3 h 0 2 h 0 1 h 0 . 5 l s b 0 1 2 3 4 0 9 3 4 0 9 4 4 0 9 5 4 0 9 6 a n a l o g i n p u t v o l t a g e 1 . 5 l s b v d d 4 0 9 6 ideal a/d transfer function
ht82a520r/ht82a620r rev.1.30 39 january 14, 2011 d 7 d 6 d 5 d 4 d 3 d 2 d 1 d 0 s b d r ( r e c e i v e d d a t a r e g i s t e r ) m u x s d o b u f f e r m u x m l s d a t a b u s m u x m a s t e r o r s l a v e s d i s d o i n t e r n a l b a u d r a t e c l o c k s c k c l o c k p o l a r i t y c 2c 1c 0 s b e n i n t e r n a l b u s y f l a g s b e n w r i t e s b d r w c o l f l a g t r f a n d , s t a r t s b e n e n a n d w r i t e s b d r w r i t e s b d r e n a b l e / d i s a b l e s c s e n m a s t e r o r s l a v e c s e n s b e n a n d , s t a r t a n d , s t a r t spi block diagram note: wcol: set by spi cleared by users csen: enable/disable chip selection function pin master mode: 1/0 = with/without scs output function slave mode: 1/0 = with/without scs input control function sben: enable/disable serial bus (0: initialise all status flags) when sben=0, all status flags should be initialised when sben=1, all spi related function pins should stay at floating state trf: 1 = data transmitted or received, 0= data is transmitting or still not received cpol: i/o = clock polarity rising/falling edge: for spir register. if clock polarity set to rising edge (spi_cpol=1), serial clock timing follow sck, otherwise (spi_cpol=0) sck is the serial clock timing. bit no. label r/w function 0 spi_cpol r/w 1: clock polarity rising 0: clock polarity falling (default falling) 1 spi_mode r/w 0: spi output the data in the rising edge(polarity=1) or falling edge (polarity=0); spi read data in the in the falling edge(polarity=1) or rising edge (polarity=0); (default) 1: spi first output the data immediately after the spi is enable. and spi output the data in the falling edge(polarity=1) or rising edge (polarity=0); spi read data in the in the rising edge(polarity=1) or falling edge (polarity=0) 2 spi_csen r/w 1: spi_csen enable , this bit is used to enable/disable software csen func - tion 0: spi_csen disable, scs define as gpio (default disable) 3 spi_en r/w this bit control the shared pin (scs , sdi, sdo and sck) is spi or gpio mode 0: i/o mode (default) 1: spi mode 7~4 reserved bit r/w always 0 spir register
ht82a520r/ht82a620r rev.1.30 40 january 14, 2011 spi operation all communication is carried out using the 4-line inter - face for both master or slave mode. the timing diagram shows the basic operation of the bus. the csen bit in the sbcr register controls the scsb line of the spi interface. setting this bit high, will enable the spi interface by allowing the scs line to be active, which can then be used to control the spi inteface. if the csen bit is low, the scs line will be in a floating condi - tion and can therefore not be used for control of the spi interface. the sben bit in the sbcr register must also be high which will place the sdi line in a floating condi - tion and the sdo line high. if in the master mode the sck line will be either high or low depending upon the clock polarity configuration option. if in the slave mode the sck line will be in a floating condition. if sben is low then the bus will be disabled and scs , sdi, sdo and sck will all be in a floating condition. in the master mode, the master will always generate the clock signal. the clock and data transmission will be ini - tiated after data has been written to the sbdr register. in the slave mode, the clock signal will be received from an external master device for both data transmission or reception. the following sequences show the order to be followed for data transfer in both master and slave mode: master mode step 1. select the clock source using the cks bit in the sbcr control register step 2. setup the m0 and m1 bits in the sbcr control register to select the master mode and the required baud rate. values of 00, 01 or 10 can be selected. step 3. setup the csen bit and setup the mls bit to choose if the data is msb or lsb first, this must be same as the slave device. step 4. setup the sben bit in the sbcr control register to enable the spi interface. step 5. for write operations: write the data to the sbdr register, which will actually place the data into the txrx buffer. then use the sck and scs lines to output the data. goto to step 6.for read operations: the data transferred in on the sdi line will be stored in the txrx buffer until all the data has been received at which point it will be latched into the sbdr register. step 6. check the wcol bit, if set high then a collision error has occurred so return to step5. if equal to zero then go to the following step. step 7. check the trf bit or wait for an spi serial bus interrupt. step 8. read data from the sbdr register. step 9. clear trf. step10. goto step 5. slave mode: step 1. the cks bit has a don t care value in the slave mode. step 2. setup the m0 and m1 bits to 11 to select the slave mode. the cks bit is don t care. step 3. setup the csen bit and setup the mls bit to choose if the data is msb or lsb first, this must be same as the master device. step 4. setup the sben bit in the sbcr control register to enable the spi interface. step 5. for write operations: write data to the sbdr register, which will actually place the data into the txrx register, then wait for the master clock and scs signal. after this goto step 6. for read operations: the data transferred in on the sdi line will be stored in the txrx buffer until all the data has been received at which point it will be latched into the sbdr register. step 6. check the wcol bit, if set high then a collision error has occurred so return to step5. if equal to zero then goto the following step. step 7. check the trf bit or wait for an spi serial bus interrupt. step 8. read data from the sbdr register. step 9. clear trf step10. step 5
ht82a520r/ht82a620r rev.1.30 41 january 14, 2011 spi configuration options and status control one option is to enable the operation of the wcol, write collision bit, in the sbcr register. some control in spir register. the spi_cpol select the clock polarity of the sck line. the spi_mode select spi data output mode. spi include four pins , can share i/o mode status . the status control combine with four bits for spir and sbcr regis - ter. include spi_csen , spi_en for spir register and csen, sben for sbcr register. control bit for register spi share function pins status spi_en spi_csen sben csen scs sck sdo sdi 0 x x x i/o mode i/o mode i/o mode i/o mode 1 0 0 x i/o mode i/o mode i/o mode i/o mode 1 0 1 x i/o mode spi mode spi mode spi mode (z) 1 1 0 x i/o mode i/o mode i/o mode i/o mode 1 1 1 0 spi mode (z) spi mode spi mode spi mode (z) 1 1 1 1 spi mode spi mode spi mode spi mode (z) note: x: dont care (z) floating s b c r r e g i s t e r b 7 b 0 c k s m 1 m 0 s b e n m l s c s e n w c o l t r f t r a n s m i t t / r e c e i v e f l a g 0 : n o t c o m p l e t e 1 : t r a n s m i s s i o n / r e c e p t i o n c o m p l e t e w r i t e c o l l i s i o n b i t 0 : c o l l i s i o n f r e e 1 : c o l l i s i o n d e t e c t e d s e l e c t i o n s i g n a l e n a b l e / d i s a b l e b i t 0 : s c s f l o a t i n g 1 : e n a b l e m s b / l s b f i r s t b i t 0 : l s b s h i f t f i r s t 1 : m s b s h i f t f i r s t s e r i a l b u s e n a b l e / d i s a b l e b i t 0 : d i s a b l e 1 : e n a b l e m a s t e r / s l a v e / b a u d r a t e b i t s m a s t e r , b a u d r a t e : f s p i m a s t e r , b a u d r a t e : f s p i / 4 m a s t e r , b a u d r a t e : f s p i / 1 6 s l a v e m o d e m 1 0 0 1 1 m 0 0 1 0 1 c l o c k s o u r c e s e l e c t b i t 0 : f s p i = f s y s / 4 1 : f s p i = f s y s spi interface control register error detection the wcol bit in the sbcr register is provided to indicate errors during data transfer. the bit is set by the serial in - terface but must be cleared by the application program. this bit indicates a data collision has occurred which hap - pens if a write to the sbdr register takes place during a data transfer operation and will prevent the write operation from continuing. the bit will be set high by the serial inter- face but has to be cleared by the user application pro- gram. the overall function of the wcol bit can be disabled or enabled by a configuration option. programming considerations when the device is placed into the power down mode note that data reception and transmission will continue. the trf bit is used to generate an interrupt when the data has been transferred or received.
ht82a520r/ht82a620r rev.1.30 42 january 14, 2011 d 7 / d 0 d 6 / d 1 d 5 / d 2 d 4 / d 3 d 3 / d 4 d 2 / d 5 d 1 / d 6 d 0 / d 7 d 7 / d 0 d 6 / d 1 d 5 / d 2 d 4 / d 3 d 3 / d 4 d 2 / d 5 d 1 / d 6 d 0 / d 7 p a 0 / s c s ( s p i _ c s e n = 1 ) d 7 / d 0 d 6 / d 1 d 5 / d 2 d 4 / d 3 d 3 / d 4 d 2 / d 5 d 1 / d 6 d 0 / d 7 p a 3 / s d o d 7 / d 0 d 6 / d 1 d 5 / d 2 d 4 / d 3 d 3 / d 4 d 2 / d 5 d 1 / d 6 d 0 / d 7 p a 2 / s d i p a 1 / s c l k ( s p i _ c p o l = 0 ) p a 1 / s c l k ( s p i _ c p o l = 1 ) s p i _ m o d e = 0 s p i _ m o d e = 1 p a 2 / s d i p a 3 / s d o p a 1 / s c l k ( s p i _ c p o l = 1 ) p a 0 / s c s ( s p i _ c s e n = 1 ) p a 1 / s c l k ( s p i _ c p o l = 0 ) s b e n = c s e n = 1 a n d w r i t e d a t a t o s b d r s b e n = 1 , c s e n = 0 a n d w r i t e d a t a t o s b d r ( i f p u l l - h i g h e d ) s b e n = c s e n = 1 a n d w r i t e d a t a t o s b d r s b e n = 1 , c s e n = 0 a n d w r i t e d a t a t o s b d r ( i f p u l l - h i g h e d ) spi bus timing
ht82a520r/ht82a620r rev.1.30 43 january 14, 2011 s b e n = 1 w r i t e d a t a i n t o s b d r w c o l = 1 ? c l e a r w c o l y e s n o r e a d d a t a f r o m s b d r c l e a r t r f t r a n s f e r f i n i s h e d ? e n d m a s t e r o r s l a v e m a s t e r s l a v e a a [ m 1 , m 0 ] = 1 1 s p i t r a n s f e r [ m 1 , m 0 ] = 0 0 , 0 1 , 1 0 s e l e c t c l o c k [ c k s ] c o n f i g u r e c s e n a n d m l s t r a n s m i s s i o n c o m p l e t e d ? ( t r f = 1 ? ) y e s y e s n o n o spi transfer control flowchart
ht82a520r/ht82a620r rev.1.30 44 january 14, 2011 usb interface the device includes a usb interface function allowing for the convenient design of usb peripheral products. ht82a620r/ht82a520r power plane there are three power planes for the device: usb sie vdd, vddio and the mcu vdd. for the usb sie vdd will supply all circuits related to the usb sie and be sourced from pin 2ubus2 . once the usb is removed from the usb and there is no power in the usb bus, the usb sie circuit is no longer operational. for the pb port, it can be configured using a configuration option to define the if the pins pb0~pb7 are supplied by either the mcu vdd, or if pins pb0~pb6 are supplied by the power pin vddio, in which case power will be sup - plied on pin pb7. in the latter configuration, pb7 will be configured as a power pin vddio and not a normal i/o pin. for the mcu vdd, it supplies all the ht82a520r/ ht82a620r circuit except the usb sie which is supply by ubus. usb suspend wake-up remote wake-up if there is no signal on the usb bus for over 3ms, the de - vice will enter a suspend mode. the suspend flag, susp, in the usc register, will then be set high and a usb inter - rupt will be generated to indicate that the device should jump to the suspend state to meet the requirements of the usb suspend current spec. in order to meet the require- ments of the suspend current, the firmware should disable the usb clock by clearing the usbcken bit to zero. the suspend current can be further decreased by setting the susp2 bit in the ucc register. when the resume sig- nal is sent out by the host, the device will be woken up the by the usb interrupt and the resume bit in the usc regis - ter will be set. to ensure correct device operation, the pro - gram must set the usbcken bit in the ucc register high and clear the susp2 bit in the ucc register. the resume signal will be cleared before the idle signal is sent out by the host and the suspend line in the usc register will change to zero. so when the mcu detects the suspend bit in the usc register, the condition of the resume line should be noted and taken into consideration. the device has a remote wake up function which can wake-up the usb host by sending a wake-up pulse through rmwk in the usc register. once the usb host receives a wake-up signal from the device it will send a resume signal to the device. usb interface operation the device has 4 endpoints, ep0~ep3. ep0 supports control transfer. all ep1~ep3 support interrupt or bulk transfer. all endpoints except ep0 can be configured as 8, 16, 32 or 64 fifo size using the register ufc0 and ufc1. ep0 has an 8-byte fifo size. the total fifo size is 64+8 bytes. the urd in the usc register is the usb reset signal con - trol function definition bit. s u s p e n d u s b r e s u m e s i g n a l u s b _ i n t s u s p e n d u s b r e s u m e s i g n a l u s b _ i n t r m w k m i n . 1 u s b c l k m i n . 2 . 5 m s
ht82a520r/ht82a620r rev.1.30 45 january 14, 2011 bit no. label r/w function 0 ? ? unused bit, read as 202 1 pub r/w 1: d+, and d- have a 500kw pull-high 0: no pull-high (default on mcu reset) 2 se0 r/w this bit is used to indicate the sie has detect a se0 noise in the usb bus. this bit is set by sie and clear by f/w. 3 se1 r/w this bit is used to indicate the sie has detect a se1 noise in the usb bus. this bit is set by sie and clear by f/w. 4 ps2/ dai r usbd-/data input. 5 ps2/ cki r usbd+/clk input. 6 ps2/ dao w output for driving usbd-/data pin, when work under 3d ps2 mouse function. default value is 212. 7 ps2/ cko w output for driving usbd+/clk pin, when work under 3d ps2 mouse function. default value is 212. usb_stat register bit no. label r/w function 0 ep0en r/w controls the usb endpoint0 interrupt. default value is 202. 1: enabled 0: disabled 1 ep1en r/w controls the usb endpoint1 interrupt. default value is 202. 1: enabled 0: disabled 2 ep2en r/w controls the usb endpoint2 interrupt. default value is 202. 1: enabled 0: disabled 3 ep3en r/w controls the usb endpoint3 interrupt. default value is 202. 1: enabled 0: disabled 4~7 ? ? unused bit, read as 202 uint1 register
ht82a520r/ht82a620r rev.1.30 46 january 14, 2011 bit no. label r/w function 0 susp r read only, usb suspend indication. when this bit is set to 212 (set by sie), it indi - cates that the usb bus has entered the suspend mode. the usb interrupt is also triggered when this bit changes from low to high. default value is 202. 1 rmwk r/w usb remote wake-up command. it is set by mcu to leave the usb host leaving the suspend mode. 2 urst r/w usb reset indication. this bit is set/cleared by the usb sie. this bit is used to de - tect a usb reset event on the usb bus. when this bit is set to 212 , this indicates that a usb reset has occurred and that a usb interrupt will be initialized. default value is 202. default value is 202. 3 resume r usb resume indication. when the usb leaves the suspend mode, this bit is set to 212 (set by sie). when the resume is set by sie, an interrupt will be generated to wake-up the mcu. in order to detect the suspend state, the mcu should set usbcken and clear susp2 (in the ucc register) to enable the sie detect func - tion. resume will be cleared when the susp goes to 202 . when the mcu is de - tecting the susp, the condition of resume (causes the mcu to wake-up) should be noted and taken into consideration. default value is 202. 4 v33o r/w 0/1: turn-off/on v33o output. default value is 202. 5 pll r/w 0: turn-on pll (default), 1: turn off pll. default value is 202. 6 selps2 r/w when set to 1 , indicated the chip work under ps2 mode. default value is 202. default value is 202. 7 urd r/w usb reset signal control function definition. 1: usb reset signal will reset mcu. (default) 0: usb reset signal cannot reset mcu. usc register the usr register which is the endpoint interrupt status register, is used to indicate which endpoint is accessed and to select the usb bus. the endpoint request flags, ep0f, ep1f, ep2f and ep3f, are used to indicate which endpoints are accessed. if an endpoint is accessed, the related endpoint request flag will be set high and a usb interrupt will be generated, if the usb interrupt is enabled and the stack is not full. when the active endpoint request flag is serviced, the endpoint request flag has to be cleared to zero using the program. bit no. label r/w function 0 ep0f r/w when this bit is set to 212 (set by sie), it indicates that endpoint 0 has been ac - cessed and a usb interrupt will occur. when the interrupt has been serviced, this bit should be cleared by software. default value is 202. 1 ep1f r/w when this bit is set to 212 (set by sie), it indicates that endpoint 1 has been ac - cessed and a usb interrupt will occur. when the interrupt has been serviced, this bit should be cleared by software. default value is 202. 2 ep2f r/w when this bit is set to 212 (set by sie), it indicates that endpoint 2 has been ac - cessed and a usb interrupt will occur. when the interrupt has been serviced, this bit should be cleared by software. default value is 202. 3 ep3f r/w when this bit is set to 212 (set by sie), it indicates that endpoint 3 has been ac - cessed and a usb interrupt will occur. when the interrupt has been serviced, this bit should be cleared by software. default value is 202. default value is 202. 4~7 ? ? unused bit, read as 202 usr register
ht82a520r/ht82a620r rev.1.30 47 january 14, 2011 there is a system clock control register to select the clock used in the mcu. this register consists of a usb clock con - trol bit, usbcken, a second suspend mode control bit, susp2, and a system clock selection bit, sysclk. the endpoint selection is determined by eps2, eps1 and eps0. bit no. label r/w function 0 1 2 eps0 eps1 eps2 r/w accessing endpoint fifo selection. default value is 20002. eps2, eps1, eps0: 000: select endpoint 0 fifo (control) 001: select endpoint 1 fifo 010: select endpoint 2 fifo 011: select endpoint 3 fifo if the selected endpoints do not exist, the related functions will be absent. 3 usbcken r/w usb clock control bit. when this bit is set to 212 , it indicates that the usb clock is enabled. otherwise, the usb clock is turned-off. default value is 202. 4 susp2 r/w this bit is used for reducing power consumption in suspend mode. in normal mode, clean this bit to 202. (default) in halt mode, set this bit to 212 for reducing power consumption. 5 fsys16mhz r/w this bit is used to define if the mcu system clock comes form an external osc or comes from the pll output 16mhz clock. 0: system clock sourced from osc. (default) 1: system clock sourced from the pll output 16mhz. 6 sysclk r/w this bit is used to specify the mcu system clock oscillator frequency. for a 6mhz crystal oscillator or resonator, set this bit to 212. for a 12mhz crystal oscillator or resonator, clear this bit to 202 . (default) 7 rctrl r/w this bit is used to control whether there is 7.5k w resistor between d+ and vbus. 0: no 7.5kw between d+ and vbus (default) 1: has 7.5kw between d+ and vbus ucc register the awr register contains the current address and a remote wake up function control bit. the initial value of awr is 200h2 . the address value extracted from the usb command has not to be loaded into this register until the setup stage has finished. bit no. label r/w function 0 wken r/w usb remote-wake-up enable/disable (1/0). default value is 202. 1~7 ad0~ad6 r/w usb device address. default value is 200000002. awr register the stall register shows if the corresponding endpoint has worked properly or not. as soon as endpoint improper op - eration occurs, the related bit in the stall register has to be set high. the stall register bits will be cleared by a usb reset signal and a setup token event. bit no. label r/w function 0~3 stl0~ stl3 r/w set by the users when related usb endpoints were stalled. cleared by a usb reset. the stl0 is also cleared by a setup token event. default value is 200002. 4~7 ? ? unused bit, read as 202 stall register
ht82a520r/ht82a620r rev.1.30 48 january 14, 2011 the sies register is only used for ep0 except for the nmi bit, which can control all endpoints bit no. label r/w function 0 aset r/w this bit is used to configure the sie to automatically change the device address by the value stored in the awr register. when this bit is set to 212 by firmware, the sie will up - date the device address by the value stored in the awr register after the pc host has successfully read the data from he device by an in operation. otherwise, when this bit is cleared to 202 , the sie will update the device address immediately after an address is written to the awr register. so, in order to work properly, the firmware has to clear this bit after a next valid setup token is received. default value is 202. 1 err r/w this bit is used to indicate that some errors have occurred when the fifo is accessed. this bit is set by sie and should be cleared by firmware. this bit is used for all endpoint. default value is 202. 2 out r/w this bit is used to indicate the out token (except the out zero length token) has been received. the firmware clears this bit after the out data has been read. also, this bit will be cleared by sie after the next valid setup token is received. default value is 202. 3 in r this bit is used to indicate the current usb receiving signal from pc host is in token. 4 no ack r this bit will set to 212 once sie discover ther are some error condition so the sie is not response (nak or ack or data) for the usb token. this bit is set by sie and clear by f/w. 5 ? ? unused bit, read as 202 6 crcf r/w this bit will set to 212 when there are the following three condition is happened: crc er - ror, pid error, bit stuffing error. this bit is set by sie and clear by f/w. default value is 202. 7 nmi r/w nak token interrupt mask flag. if this bit set, when the device sent a nak token to the host, an interrupt will be disabled. otherwise if this bit is cleared, when the device sends a nak token to the host, it will enter the interrupt sub-routine. this bit is used for all endpoint. default value is 202. sies register the misc register combines command and status to control the desired endpoint fifo action and to show the status of the desired endpoint fifo. misc will be cleared by a usb reset signal. bit no. label r/w function 0 request r/w after setting the status of the desired one, fifo can be requested by setting this bit high. after finishing, this bit must be set low. default value is 202. 1 tx r/w to represent the direction and transition end mcu access. when set to logic 1, the mcu desires to write data to the fifo. after finishing, this bit must be set to logic 0 before terminating request to represent transition end. for an mcu read operation, this bit must be set to logic 0 and set to logic 1 after finishing. default value is 202. 2 clear r/w mcu requests to clear the fifo, even if the fifo is not ready. after clearing the fifo, the usb interface will send force_tx_err to tell the host that data under-run if the host wants to read data. default value is 202. 3~4 ? ? unused bit, read as 202 5 setcmd r/w to show that the data in the fifo is a setup command. this bit is set by hardware and clear by firmware. default value is 202. 6 ready r to show that the desired fifo is ready. 7 len0 r to show that the host sent a 0-sized packet to the mcu. this bit must be cleared by a read action to the corresponding fifo. misc register
ht82a520r/ht82a620r rev.1.30 49 january 14, 2011 bit no. label r/w function 0 fifo_def r/w once this bit set to 212 by firmware, the sie should redefine the fifo configura - tion. this bit is automatically cleared by sie 1 seti1* r/w input fifo for ep1 enable 1/disable 0; default disable 2 seti2* r/w input fifo for ep2 enable 1/disable 0; default disable 3 seti3* r/w input fifo for ep3 enable 1/disable 0; default disable 4~7 ? ? unused bit, read as 202 note: 2*2 it is only required to set the data pipe as an input pile or output pile. the purpose of this function is to avoid the host sending an abnormal in or out token and disabling the endpoint. ufien register, usb endpoint 1~endpoint 3 set in pipe enable register. bit no. label r/w function 0 ? ? unused bit, read as 202 1 seto1** r/w output fifo for ep1 enable 1/disable 0; default disable 2 seto2** r/w output fifo for ep2 enable 1/disable 0; default disable 3 seto3** r/w output fifo for ep3 enable 1/disable 0; default disable 4~7 ? ? unused bit, read as 202 note: 2*2 usb definition: when the host sends a 2 set configuration2 , the data pipe should send the data0 (about the data toggle) first. so, when the device receives a 2 set configuration2 setup command, the user needs to toggle this bit as the following data will send a data0 first. 2**2 it is only required to set the data pipe as an input pile or output pile. the purpose of this function is to avoid the host sending a abnormal in or out token and disabling the endpoint. ufoen register, usb endpoint 1~endpoint 3 set out pipe enable register bit no. label r/w function 0 1 ram_def0 ram_def1 r/w 00: ram0 input fifo, ram1 output fifo (default) 01: both ram0 and ram1 are output fifo 10: both ram0 and ram1 are input fifo 11: ram0 output fifo, ram1 input fifo 2 3 e1fs0 e1fs1 r/w define endpoint 1 fifo size e1fs1, e1fs0: 00: 8-byte (default) 01: 16-byte 10: 32-byte 11: 64-byte 4 5 e2fs0 e2fs1 r/w define endpoint 2 fifo size e2fs1, e2fs0: 00: 8-byte (default) 01: 16-byte 10: 32-byte 11: 64-byte 6 7 e3fs0 e3fs1 r/w define endpoint 3 fifo size e3fs1, e3fs0: 00: 8-byte (default) 01: 16-byte 10: 32-byte 11: 64-byte ufc0 usb fifo size control register 0
ht82a520r/ht82a620r rev.1.30 50 january 14, 2011 the total fifo size is 64+8 bytes. all endpoints except ep0 can be defined by registers ufoen, ufien, ufc0 and ufc. there are three fifo mapped as follow: 8 bytes fifo for endpoint0 ram0 fifo for other input endpoint (1~3) ram1 fifo for other output endpoint (1~3) label r/w function fifo0~fifo3 r/w epi accessing register (i=0~3). when an endpoint is disabled, the corresponding ac - cessing register should be disabled. fifo0~fifo3 usb endpoint accessing registers definitions configuration options no. options 1 pa pull-high enable/disable by bit 2 pb pull-high enable/disable by nibble 3 pc pull-high enable/disable by nibble 4 pb wake-up enable/disable by nibble 5 pc wake-up enable/disable by nibble 6 usb d- pin internal 1.5k w resistor enable/disable 7 usb d+ pin internal 7.5k w resistor enable/disable 8 tbhp enable or disable 9 low voltage reset: enable/disable 10 wdt enable/disable 11 wdt clock source: f sys /4 or wdtosc (32k rc) 12 clr wdt instructions: one or two clear wdt instruction(s) 13 pa nmos or cmos output type 14 pa wake-up enable/disable by bit 16 pb7 mode: gpio or v ddio pin for pb0~pb6 power source 17 vdd pb0~pb6: pb0~pb6 power source from v dd or v ddio 18 spi_wcol: enable/disable
application circuits crystal or ceramic resonator for multiple i/o applications note: the resistance and capacitance for reset circuit should be designed in such a way as to ensure that vdd is sta - ble and remains within a valid operating voltage range before bringing res high. x1 can use 6mhz or 12mhz, x1 as close osc1 & osc2 as possible. * these capacitors should be placed close to the usb connector. ** this capacitor should be placed close to the mcu. ht82a520r/ht82a620r rev.1.30 51 january 14, 2011 h t 8 2 a 5 2 0 r / h t 8 2 a 6 2 0 r p a 0 ~ p a 7 p b 0 ~ p b 7 p c 0 ~ p c 7 u s b d + / c l k u s b d - / d a t a v 3 3 o 1 . 5 k w v d d u s b - u s b + v s s 3 3 w 3 3 w 0 . 1 m f 0 . 1 m f * v d d o s c 1 o s c 2 r e s v s s 0 . 1 m f 1 0 0 k w 1 0 m f * x 1 0 . 1 m f * *
ht82a520r/ht82a620r rev.1.30 52 january 14, 2011 instruction set introduction c e n t r a l t o t h e s u c c e s s f u l o p e r a t i o n o f a n y microcontroller is its instruction set, which is a set of pro - gram instruction codes that directs the microcontroller to perform certain operations. in the case of holtek microcontrollers, a comprehensive and flexible set of over 60 instructions is provided to enable programmers to implement their application with the minimum of pro - gramming overheads. for easier understanding of the various instruction codes, they have been subdivided into several func - tional groupings. instruction timing most instructions are implemented within one instruc - tion cycle. the exceptions to this are branch, call, or ta - ble read instructions where two instruction cycles are required. one instruction cycle is equal to 4 system clock cycles, therefore in the case of an 8mhz system oscillator, most instructions would be implemented within 0.5 m s and branch or call instructions would be im - plemented within 1 m s. although instructions which re - quire one more cycle to implement are generally limited to the jmp, call, ret, reti and table read instruc - tions, it is important to realize that any other instructions which involve manipulation of the program counter low register or pcl will also take one more cycle to imple - ment. as instructions which change the contents of the pcl will imply a direct jump to that new address, one more cycle will be required. examples of such instruc- tions would be 2 clr pcl2 or 2 mov pcl, a2 . for the case of skip instructions, it must be noted that if the re - sult of the comparison involves a skip operation then this will also take one more cycle, if no skip is involved then only one cycle is required. moving and transferring data the transfer of data within the microcontroller program is one of the most frequently used operations. making use of three kinds of mov instructions, data can be transferred from registers to the accumulator and vice-versa as well as being able to move specific imme - diate data directly into the accumulator. one of the most important data transfer applications is to receive data from the input ports and transfer data to the output ports. arithmetic operations the ability to perform certain arithmetic operations and data manipulation is a necessary feature of most microcontroller applications. within the holtek microcontroller instruction set are a range of add and subtract instruction mnemonics to enable the necessary arithmetic to be carried out. care must be taken to en - sure correct handling of carry and borrow data when re - sults exceed 255 for addition and less than 0 for subtraction. the increment and decrement instructions inc, inca, dec and deca provide a simple means of increasing or decreasing by a value of one of the values in the destination specified. logical and rotate operations the standard logical operations such as and, or, xor and cpl all have their own instruction within the holtek microcontroller instruction set. as with the case of most instructions involving data manipulation, data must pass through the accumulator which may involve additional programming steps. in all logical data operations, the zero flag may be set if the result of the operation is zero. another form of logical data manipulation comes from the rotate instructions such as rr, rl, rrc and rlc which provide a simple means of rotating one bit right or left. different rotate instructions exist depending on pro - gram requirements. rotate instructions are useful for serial port programming applications where data can be rotated from an internal register into the carry bit from where it can be examined and the necessary serial bit set high or low. another application where rotate data operations are used is to implement multiplication and division calculations. branches and control transfer program branching takes the form of either jumps to specified locations using the jmp instruction or to a sub- routine using the call instruction. they differ in the sense that in the case of a subroutine call, the program must return to the instruction immediately when the sub - routine has been carried out. this is done by placing a return instruction ret in the subroutine which will cause the program to jump back to the address right after the call instruction. in the case of a jmp instruction, the program simply jumps to the desired location. there is no requirement to jump back to the original jumping off point as in the case of the call instruction. one special and extremely useful set of branch instructions are the conditional branches. here a decision is first made re - garding the condition of a certain data memory or indi - vidual bits. depending upon the conditions, the program will continue with the next instruction or skip over it and jump to the following instruction. these instructions are the key to decision making and branching within the pro - gram perhaps determined by the condition of certain in - put switches or by the condition of internal data bits.
ht82a520r/ht82a620r rev.1.30 53 january 14, 2011 bit operations the ability to provide single bit operations on data mem - ory is an extremely flexible feature of all holtek microcontrollers. this feature is especially useful for output port bit programming where individual bits or port pins can be directly set high or low using either the 2set [m].i2 or 2 clr [m].i2 instructions respectively. the fea - ture removes the need for programmers to first read the 8-bit output port, manipulate the input data to ensure that other bits are not changed and then output the port with the correct new data. this read-modify-write pro - cess is taken care of automatically when these bit oper - ation instructions are used. table read operations data storage is normally implemented by using regis - ters. however, when working with large amounts of fixed data, the volume involved often makes it inconve - nient to store the fixed data in the data memory. to over - come this problem, holtek microcontrollers allow an area of program memory to be setup as a table where data can be directly stored. a set of easy to use instruc - tions provides the means by which this fixed data can be referenced and retrieved from the program memory. other operations in addition to the above functional instructions, a range of other instructions also exist such as the 2 halt2 in - struction for power-down operations and instructions to control the operation of the watchdog timer for reliable program operations under extreme electric or electro - magnetic environments. for their relevant operations, refer to the functional related sections. instruction set summary the following table depicts a summary of the instruction set categorised according to function and can be con - sulted as a basic instruction reference using the follow - ing listed conventions. table conventions: x: bits immediate data m: data memory address a: accumulator i: 0~7 number of bits addr: program memory address mnemonic description cycles flag affected arithmetic add a,[m] addm a,[m] add a,x adc a,[m] adcm a,[m] sub a,x sub a,[m] subm a,[m] sbc a,[m] sbcm a,[m] daa [m] add data memory to acc add acc to data memory add immediate data to acc add data memory to acc with carry add acc to data memory with carry subtract immediate data from the acc subtract data memory from acc subtract data memory from acc with result in data memory subtract data memory from acc with carry subtract data memory from acc with carry, result in data memory decimal adjust acc for addition with result in data memory 1 1 note 1 1 1 note 1 1 1 note 1 1 note 1 note z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov c logic operation and a,[m] or a,[m] xor a,[m] andm a,[m] orm a,[m] xorm a,[m] and a,x or a,x xor a,x cpl [m] cpla [m] logical and data memory to acc logical or data memory to acc logical xor data memory to acc logical and acc to data memory logical or acc to data memory logical xor acc to data memory logical and immediate data to acc logical or immediate data to acc logical xor immediate data to acc complement data memory complement data memory with result in acc 1 1 1 1 note 1 note 1 note 1 1 1 1 note 1 z z z z z z z z z z z increment & decrement inca [m] inc [m] deca [m] dec [m] increment data memory with result in acc increment data memory decrement data memory with result in acc decrement data memory 1 1 note 1 1 note z z z z
ht82a520r/ht82a620r rev.1.30 54 january 14, 2011 mnemonic description cycles flag affected rotate rra [m] rr [m] rrca [m] rrc [m] rla [m] rl [m] rlca [m] rlc [m] rotate data memory right with result in acc rotate data memory right rotate data memory right through carry with result in acc rotate data memory right through carry rotate data memory left with result in acc rotate data memory left rotate data memory left through carry with result in acc rotate data memory left through carry 1 1 note 1 1 note 1 1 note 1 1 note none none c c none none c c data move mov a,[m] mov [m],a mov a,x move data memory to acc move acc to data memory move immediate data to acc 1 1 note 1 none none none bit operation clr [m].i set [m].i clear bit of data memory set bit of data memory 1 note 1 note none none branch jmp addr sz [m] sza [m] sz [m].i snz [m].i siz [m] sdz [m] siza [m] sdza [m] call addr ret ret a,x reti jump unconditionally skip if data memory is zero skip if data memory is zero with data movement to acc skip if bit i of data memory is zero skip if bit i of data memory is not zero skip if increment data memory is zero skip if decrement data memory is zero skip if increment data memory is zero with result in acc skip if decrement data memory is zero with result in acc subroutine call return from subroutine return from subroutine and load immediate data to acc return from interrupt 2 1 note 1 note 1 note 1 note 1 note 1 note 1 note 1 note 2 2 2 2 none none none none none none none none none none none none none table read tabrdc [m] (4) tabrdc [m] (5) tabrdl [m] read rom code (locate by tblp and tbhp) to data memory and tblh read rom code (current page) to data memory and tblh read table (last page) to tblh and data memory 2 note 2 note 2 note none none none miscellaneous nop clr [m] set [m] clr wdt clr wdt1 clr wdt2 swap [m] swapa [m] halt no operation clear data memory set data memory clear watchdog timer pre-clear watchdog timer pre-clear watchdog timer swap nibbles of data memory swap nibbles of data memory with result in acc enter power down mode 1 1 note 1 note 1 1 1 1 note 1 1 none none none to, pdf to, pdf to, pdf none none to, pdf note: 1. for skip instructions, if the result of the comparison involves a skip then two cycles are required, if no skip takes place only one cycle is required. 2. any instruction which changes the contents of the pcl will also require 2 cycles for execution. 3. for the 2 clr wdt12 and 2 clr wdt22 instructions the to and pdf flags may be affected by the execution status. the to and pdf flags are cleared after both 2 clr wdt12 and 2 clr wdt22 instructions are consecutively executed. otherwise the to and pdf flags remain unchanged. 4. configuration option 2 tbhp option2 is enabled 5. configuration option 2 tbhp option2 is disabled
instruction definition adc a,[m] add data memory to acc with carry description the contents of the specified data memory, accumulator and the carry flag are added. the result is stored in the accumulator. operation acc ? acc + [m] + c affected flag(s) ov, z, ac, c adcm a,[m] add acc to data memory with carry description the contents of the specified data memory, accumulator and the carry flag are added. the result is stored in the specified data memory. operation [m] ? acc + [m] + c affected flag(s) ov, z, ac, c add a,[m] add data memory to acc description the contents of the specified data memory and the accumulator are added. the result is stored in the accumulator. operation acc ? acc + [m] affected flag(s) ov, z, ac, c add a,x add immediate data to acc description the contents of the accumulator and the specified immediate data are added. the result is stored in the accumulator. operation acc ? acc + x affected flag(s) ov, z, ac, c addm a,[m] add acc to data memory description the contents of the specified data memory and the accumulator are added. the result is stored in the specified data memory. operation [m] ? acc + [m] affected flag(s) ov, z, ac, c and a,[m] logical and data memory to acc description data in the accumulator and the specified data memory perform a bitwise logical and op - eration. the result is stored in the accumulator. operation acc ? acc 2and2 [m] affected flag(s) z and a,x logical and immediate data to acc description data in the accumulator and the specified immediate data perform a bitwise logical and operation. the result is stored in the accumulator. operation acc ? acc 2and2 x affected flag(s) z andm a,[m] logical and acc to data memory description data in the specified data memory and the accumulator perform a bitwise logical and op - eration. the result is stored in the data memory. operation [m] ? acc 2and2 [m] affected flag(s) z ht82a520r/ht82a620r rev.1.30 55 january 14, 2011
call addr subroutine call description unconditionally calls a subroutine at the specified address. the program counter then in - crements by 1 to obtain the address of the next instruction which is then pushed onto the stack. the specified address is then loaded and the program continues execution from this new address. as this instruction requires an additional operation, it is a two cycle instruc - tion. operation stack ? program counter + 1 program counter ? addr affected flag(s) none clr [m] clear data memory description each bit of the specified data memory is cleared to 0. operation [m] ? 00h affected flag(s) none clr [m].i clear bit of data memory description bit i of the specified data memory is cleared to 0. operation [m].i ? 0 affected flag(s) none clr wdt clear watchdog timer description the to, pdf flags and the wdt are all cleared. operation wdt cleared to ? 0 pdf ? 0 affected flag(s) to, pdf clr wdt1 pre-clear watchdog timer description the to, pdf flags and the wdt are all cleared. note that this instruction works in conjunc- tion with clr wdt2 and must be executed alternately with clr wdt2 to have effect. re- petitively executing this instruction without alternately executing clr wdt2 will have no effect. operation wdt cleared to ? 0 pdf ? 0 affected flag(s) to, pdf clr wdt2 pre-clear watchdog timer description the to, pdf flags and the wdt are all cleared. note that this instruction works in conjunc - tion with clr wdt1 and must be executed alternately with clr wdt1 to have effect. re - petitively executing this instruction without alternately executing clr wdt1 will have no effect. operation wdt cleared to ? 0 pdf ? 0 affected flag(s) to, pdf ht82a520r/ht82a620r rev.1.30 56 january 14, 2011
cpl [m] complement data memory description each bit of the specified data memory is logically complemented (1 s complement). bits which previously contained a 1 are changed to 0 and vice versa. operation [m] ? [m] affected flag(s) z cpla [m] complement data memory with result in acc description each bit of the specified data memory is logically complemented (1 s complement). bits which previously contained a 1 are changed to 0 and vice versa. the complemented result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc ? [m] affected flag(s) z daa [m] decimal-adjust acc for addition with result in data memory description convert the contents of the accumulator value to a bcd ( binary coded decimal) value re - sulting from the previous addition of two bcd variables. if the low nibble is greater than 9 or if ac flag is set, then a value of 6 will be added to the low nibble. otherwise the low nibble remains unchanged. if the high nibble is greater than 9 or if the c flag is set, then a value of 6 will be added to the high nibble. essentially, the decimal conversion is performed by add - ing 00h, 06h, 60h or 66h depending on the accumulator and flag conditions. only the c flag may be affected by this instruction which indicates that if the original bcd sum is greater than 100, it allows multiple precision decimal addition. operation [m] ? acc + 00h or [m] ? acc + 06h or [m] ? acc + 60h or [m] ? acc + 66h affected flag(s) c dec [m] decrement data memory description data in the specified data memory is decremented by 1. operation [m] ? [m] - 1 affected flag(s) z deca [m] decrement data memory with result in acc description data in the specified data memory is decremented by 1. the result is stored in the accu - mulator. the contents of the data memory remain unchanged. operation acc ? [m] - 1 affected flag(s) z halt enter power down mode description this instruction stops the program execution and turns off the system clock. the contents of the data memory and registers are retained. the wdt and prescaler are cleared. the power down flag pdf is set and the wdt time-out flag to is cleared. operation to ? 0 pdf ? 1 affected flag(s) to, pdf ht82a520r/ht82a620r rev.1.30 57 january 14, 2011
inc [m] increment data memory description data in the specified data memory is incremented by 1. operation [m] ? [m] + 1 affected flag(s) z inca [m] increment data memory with result in acc description data in the specified data memory is incremented by 1. the result is stored in the accumu - lator. the contents of the data memory remain unchanged. operation acc ? [m] + 1 affected flag(s) z jmp addr jump unconditionally description the contents of the program counter are replaced with the specified address. program execution then continues from this new address. as this requires the insertion of a dummy instruction while the new address is loaded, it is a two cycle instruction. operation program counter ? addr affected flag(s) none mov a,[m] move data memory to acc description the contents of the specified data memory are copied to the accumulator. operation acc ? [m] affected flag(s) none mov a,x move immediate data to acc description the immediate data specified is loaded into the accumulator. operation acc ? x affected flag(s) none mov [m],a move acc to data memory description the contents of the accumulator are copied to the specified data memory. operation [m] ? acc affected flag(s) none nop no operation description no operation is performed. execution continues with the next instruction. operation no operation affected flag(s) none or a,[m] logical or data memory to acc description data in the accumulator and the specified data memory perform a bitwise logical or oper - ation. the result is stored in the accumulator. operation acc ? acc 2or2 [m] affected flag(s) z ht82a520r/ht82a620r rev.1.30 58 january 14, 2011
or a,x logical or immediate data to acc description data in the accumulator and the specified immediate data perform a bitwise logical or op - eration. the result is stored in the accumulator. operation acc ? acc 2or2 x affected flag(s) z orm a,[m] logical or acc to data memory description data in the specified data memory and the accumulator perform a bitwise logical or oper - ation. the result is stored in the data memory. operation [m] ? acc 2or2 [m] affected flag(s) z ret return from subroutine description the program counter is restored from the stack. program execution continues at the re - stored address. operation program counter ? stack affected flag(s) none ret a,x return from subroutine and load immediate data to acc description the program counter is restored from the stack and the accumulator loaded with the specified immediate data. program execution continues at the restored address. operation program counter ? stack acc ? x affected flag(s) none reti return from interrupt description the program counter is restored from the stack and the interrupts are re-enabled by set- ting the emi bit. emi is the master interrupt global enable bit. if an interrupt was pending when the reti instruction is executed, the pending interrupt routine will be processed be- fore returning to the main program. operation program counter ? stack emi ? 1 affected flag(s) none rl [m] rotate data memory left description the contents of the specified data memory are rotated left by 1 bit with bit 7 rotated into bit 0. operation [m].(i+1) ? [m].i; (i = 0~6) [m].0 ? [m].7 affected flag(s) none rla [m] rotate data memory left with result in acc description the contents of the specified data memory are rotated left by 1 bit with bit 7 rotated into bit 0. the rotated result is stored in the accumulator and the contents of the data memory re - main unchanged. operation acc.(i+1) ? [m].i; (i = 0~6) acc.0 ? [m].7 affected flag(s) none ht82a520r/ht82a620r rev.1.30 59 january 14, 2011
rlc [m] rotate data memory left through carry description the contents of the specified data memory and the carry flag are rotated left by 1 bit. bit 7 replaces the carry bit and the original carry flag is rotated into bit 0. operation [m].(i+1) ? [m].i; (i = 0~6) [m].0 ? c c ? [m].7 affected flag(s) c rlca [m] rotate data memory left through carry with result in acc description data in the specified data memory and the carry flag are rotated left by 1 bit. bit 7 replaces the carry bit and the original carry flag is rotated into the bit 0. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.(i+1) ? [m].i; (i = 0~6) acc.0 ? c c ? [m].7 affected flag(s) c rr [m] rotate data memory right description the contents of the specified data memory are rotated right by 1 bit with bit 0 rotated into bit 7. operation [m].i ? [m].(i+1); (i = 0~6) [m].7 ? [m].0 affected flag(s) none rra [m] rotate data memory right with result in acc description data in the specified data memory and the carry flag are rotated right by 1 bit with bit 0 ro- tated into bit 7. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.i ? [m].(i+1); (i = 0~6) acc.7 ? [m].0 affected flag(s) none rrc [m] rotate data memory right through carry description the contents of the specified data memory and the carry flag are rotated right by 1 bit. bit 0 replaces the carry bit and the original carry flag is rotated into bit 7. operation [m].i ? [m].(i+1); (i = 0~6) [m].7 ? c c ? [m].0 affected flag(s) c rrca [m] rotate data memory right through carry with result in acc description data in the specified data memory and the carry flag are rotated right by 1 bit. bit 0 re - places the carry bit and the original carry flag is rotated into bit 7. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.i ? [m].(i+1); (i = 0~6) acc.7 ? c c ? [m].0 affected flag(s) c ht82a520r/ht82a620r rev.1.30 60 january 14, 2011
sbc a,[m] subtract data memory from acc with carry description the contents of the specified data memory and the complement of the carry flag are sub - tracted from the accumulator. the result is stored in the accumulator. note that if the result of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation acc ? acc - [m] - c affected flag(s) ov, z, ac, c sbcm a,[m] subtract data memory from acc with carry and result in data memory description the contents of the specified data memory and the complement of the carry flag are sub - tracted from the accumulator. the result is stored in the data memory. note that if the re - sult of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation [m] ? acc - [m] - c affected flag(s) ov, z, ac, c sdz [m] skip if decrement data memory is 0 description the contents of the specified data memory are first decremented by 1. if the result is 0 the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation [m] ? [m] - 1 skip if [m] = 0 affected flag(s) none sdza [m] skip if decrement data memory is zero with result in acc description the contents of the specified data memory are first decremented by 1. if the result is 0, the following instruction is skipped. the result is stored in the accumulator but the specified data memory contents remain unchanged. as this requires the insertion of a dummy in- struction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0, the program proceeds with the following instruction. operation acc ? [m] - 1 skip if acc = 0 affected flag(s) none set [m] set data memory description each bit of the specified data memory is set to 1. operation [m] ? ffh affected flag(s) none set [m].i set bit of data memory description bit i of the specified data memory is set to 1. operation [m].i ? 1 affected flag(s) none ht82a520r/ht82a620r rev.1.30 61 january 14, 2011
siz [m] skip if increment data memory is 0 description the contents of the specified data memory are first incremented by 1. if the result is 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation [m] ? [m] + 1 skip if [m] = 0 affected flag(s) none siza [m] skip if increment data memory is zero with result in acc description the contents of the specified data memory are first incremented by 1. if the result is 0, the following instruction is skipped. the result is stored in the accumulator but the specified data memory contents remain unchanged. as this requires the insertion of a dummy in - struction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation acc ? [m] + 1 skip if acc = 0 affected flag(s) none snz [m].i skip if bit i of data memory is not 0 description if bit i of the specified data memory is not 0, the following instruction is skipped. as this re - quires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is 0 the program proceeds with the following instruction. operation skip if [m].i 1 0 affected flag(s) none sub a,[m] subtract data memory from acc description the specified data memory is subtracted from the contents of the accumulator. the result is stored in the accumulator. note that if the result of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation acc ? acc - [m] affected flag(s) ov, z, ac, c subm a,[m] subtract data memory from acc with result in data memory description the specified data memory is subtracted from the contents of the accumulator. the result is stored in the data memory. note that if the result of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation [m] ? acc - [m] affected flag(s) ov, z, ac, c sub a,x subtract immediate data from acc description the immediate data specified by the code is subtracted from the contents of the accumu - lator. the result is stored in the accumulator. note that if the result of subtraction is nega - tive, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation acc ? acc - x affected flag(s) ov, z, ac, c ht82a520r/ht82a620r rev.1.30 62 january 14, 2011
swap [m] swap nibbles of data memory description the low-order and high-order nibbles of the specified data memory are interchanged. operation [m].3~[m].0 ? [m].7 ~ [m].4 affected flag(s) none swapa [m] swap nibbles of data memory with result in acc description the low-order and high-order nibbles of the specified data memory are interchanged. the result is stored in the accumulator. the contents of the data memory remain unchanged. operation acc.3 ~ acc.0 ? [m].7 ~ [m].4 acc.7 ~ acc.4 ? [m].3 ~ [m].0 affected flag(s) none sz [m] skip if data memory is 0 description if the contents of the specified data memory is 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruc - tion. operation skip if [m] = 0 affected flag(s) none sza [m] skip if data memory is 0 with data movement to acc description the contents of the specified data memory are copied to the accumulator. if the value is zero, the following instruction is skipped. as this requires the insertion of a dummy instruc - tion while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation acc ? [m] skip if [m] = 0 affected flag(s) none sz [m].i skip if bit i of data memory is 0 description if bit i of the specified data memory is 0, the following instruction is skipped. as this re - quires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0, the program proceeds with the following instruction. operation skip if [m].i = 0 affected flag(s) none tabrdc [m] read table (current page) to tblh and data memory description the low byte of the program code (current page) addressed by the table pointer (tblp) is moved to the specified data memory and the high byte moved to tblh. operation [m] ? program code (low byte) tblh ? program code (high byte) affected flag(s) none tabrdc [m] move the rom code (locate by tblp and tbhp) to tblh and data memory (rom code tbhp is enabled) description the low byte of rom code addressed by the table pointers (tblp and tbhp) is moved to the specified data memory and the high byte transferred to tblh directly. operation [m] ? program code (low byte) tblh ? program code (high byte) affected flag(s) none ht82a520r/ht82a620r rev.1.30 63 january 14, 2011
tabrdl [m] read table (last page) to tblh and data memory description the low byte of the program code (last page) addressed by the table pointer (tblp) is moved to the specified data memory and the high byte moved to tblh. operation [m] ? program code (low byte) tblh ? program code (high byte) affected flag(s) none xor a,[m] logical xor data memory to acc description data in the accumulator and the specified data memory perform a bitwise logical xor op - eration. the result is stored in the accumulator. operation acc ? acc 2xor2 [m] affected flag(s) z xorm a,[m] logical xor acc to data memory description data in the specified data memory and the accumulator perform a bitwise logical xor op - eration. the result is stored in the data memory. operation [m] ? acc 2xor2 [m] affected flag(s) z xor a,x logical xor immediate data to acc description data in the accumulator and the specified immediate data perform a bitwise logical xor operation. the result is stored in the accumulator. operation acc ? acc 2xor2 x affected flag(s) z ht82a520r/ht82a620r rev.1.30 64 january 14, 2011
package information 20-pin ssop (150mil) outline dimensions symbol dimensions in inch min. nom. max. a 0.228 ? 0.244 b 0.150 ? 0.158 c 0.008 ? 0.012 c 0.335 ? 0.347 d 0.049 ? 0.065 e ? 0.025 ? f 0.004 ? 0.010 g 0.015 ? 0.050 h 0.007 ? 0.010 a 0 ? 8 symbol dimensions in mm min. nom. max. a 5.79 ? 6.20 b 3.81 ? 4.01 c 0.20 ? 0.30 c 8.51 ? 8.81 d 1.24 ? 1.65 e ? 0.64 ? f 0.10 ? 0.25 g 0.38 ? 1.27 h 0.18 ? 0.25 a 0 ? 8 ht82a520r/ht82a620r rev.1.30 65 january 14, 2011 2 0 1 1 1 1 0 a b c d e f c ' g h a
24-pin ssop (150mil) outline dimensions symbol dimensions in inch min. nom. max. a 0.228 ? 0.244 b 0.150 ? 0.157 c 0.008 ? 0.012 c 0.335 ? 0.346 d 0.054 ? 0.060 e ? 0.025 ? f 0.004 ? 0.010 g 0.022 ? 0.028 h 0.007 ? 0.010 a 0 ? 8 symbol dimensions in mm min. nom. max. a 5.79 ? 6.20 b 3.81 ? 3.99 c 0.20 ? 0.30 c 8.51 ? 8.79 d 1.37 ? 1.52 e ? 0.64 ? f 0.10 ? 0.25 g 0.56 ? 0.71 h 0.18 ? 0.25 a 0 ? 8 ht82a520r/ht82a620r rev.1.30 66 january 14, 2011 2 4 1 1 3 1 2 a b c d e f c ' g h a
28-pin ssop (150mil) outline dimensions symbol dimensions in inch min. nom. max. a 0.228 ? 0.244 b 0.150 ? 0.157 c 0.008 ? 0.012 c 0.386 ? 0.394 d 0.054 ? 0.060 e ? 0.025 ? f 0.004 ? 0.010 g 0.022 ? 0.028 h 0.007 ? 0.010 a 0 ? 8 symbol dimensions in mm min. nom. max. a 5.79 ? 6.20 b 3.81 ? 3.99 c 0.20 ? 0.30 c 9.80 ? 10.01 d 1.37 ? 1.52 e ? 0.64 ? f 0.10 ? 0.25 g 0.56 ? 0.71 h 0.18 ? 0.25 a 0 ? 8 ht82a520r/ht82a620r rev.1.30 67 january 14, 2011 2 8 1 1 5 1 4 a b c d f c ' g h a e
saw type 32-pin (5mm5mm) qfn outline dimensions symbol dimensions in inch min. nom. max. a 0.028 ? 0.031 a1 0.000 ? 0.002 a3 ? 0.008 ? b 0.007 ? 0.012 d ? 0.197 ? e ? 0.197 ? e ? 0.020 ? d2 0.049 ? 0.128 e2 0.049 ? 0.128 l 0.012 ? 0.020 k ? ? ? symbol dimensions in mm min. nom. max. a 0.70 ? 0.80 a1 0.00 ? 0.05 a3 ? 0.20 ? b 0.18 ? 0.30 d ? 5.00 ? e ? 5.00 ? e ? 0.50 ? d2 1.25 ? 3.25 e2 1.25 ? 3.25 l 0.30 ? 0.50 k ? ? ? ht82a520r/ht82a620r rev.1.30 68 january 14, 2011 d e e b a 1 a 3 a d 2 l e 2 k 1 8 9 1 6 1 7 2 4 2 5 3 2
product tape and reel specifications reel dimensions ssop 20s (150mil), ssop 24s (150mil), ssop 28s (150mil) symbol description dimensions in mm a reel outer diameter 330.01.0 b reel inner diameter 100.01.5 c spindle hole diameter 13.0 +0.5/-0.2 d key slit width 2.00.5 t1 space between flange 16.8 +0.3/-0.2 t2 reel thickness 22.20.2 ht82a520r/ht82a620r rev.1.30 69 january 14, 2011 a c b t 1 t 2 d
carrier tape dimensions ssop 20s (150mil) symbol description dimensions in mm w carrier tape width 16.0 +0.3/-0.1 p cavity pitch 8.00.1 e perforation position 1.750.10 f cavity to perforation (width direction) 7.50.1 d perforation diameter 1.5 +0.1/-0.0 d1 cavity hole diameter 1.50 +0.25/-0.00 p0 perforation pitch 4.00.1 p1 cavity to perforation (length direction) 2.00.1 a0 cavity length 6.50.1 b0 cavity width 9.00.1 k0 cavity depth 2.30.1 t carrier tape thickness 0.300.05 c cover tape width 13.30.1 ht82a520r/ht82a620r rev.1.30 70 january 14, 2011 p d 1 w p 1 p 0 d e f t k 0 b 0 a 0 c i c p a c k a g e p i n 1 a n d t h e r e e l h o l e s a r e l o c a t e d o n t h e s a m e s i d e . r e e l h o l e
ssop 24s (150mil) symbol description dimensions in mm w carrier tape width 16.0 +0.3/-0.1 p cavity pitch 8.00.1 e perforation position 1.750.10 f cavity to perforation (width direction) 7.50.1 d perforation diameter 1.5 +0.1/-0.0 d1 cavity hole diameter 1.50 +0.25/-0.00 p0 perforation pitch 4.00.1 p1 cavity to perforation (length direction) 2.00.1 a0 cavity length 6.50.1 b0 cavity width 9.50.1 k0 cavity depth 2.10.1 t carrier tape thickness 0.300.05 c cover tape width 13.30.1 ssop 28s (150mil) symbol description dimensions in mm w carrier tape width 16.00.3 p cavity pitch 8.00.1 e perforation position 1.750.1 f cavity to perforation (width direction) 7.50.1 d perforation diameter 1.55 +0.10/-0.00 d1 cavity hole diameter 1.50 +0.25/-0.00 p0 perforation pitch 4.00.1 p1 cavity to perforation (length direction) 2.00.1 a0 cavity length 6.50.1 b0 cavity width 10.30.1 k0 cavity depth 2.10.1 t carrier tape thickness 0.300.05 c cover tape width 13.30.1 ht82a520r/ht82a620r rev.1.30 71 january 14, 2011
ht82a520r/ht82a620r rev.1.30 72 january 14, 2011 copyright 2011 by holtek semiconductor inc. the information appearing in this data sheet is believed to be accurate at the time of publication. however, holtek as - sumes no responsibility arising from the use of the specifications described. the applications mentioned herein are used solely for the purpose of illustration and holtek makes no warranty or representation that such applications will be suitable without further modification, nor recommends the use of its products for application that may present a risk to human life due to malfunction or otherwise. holtek s products are not authorized for use as critical components in life support devices or systems. holtek reserves the right to alter its products without prior notification. for the most up-to-date information, please visit our web site at http://www.holtek.com.tw. holtek semiconductor inc. (headquarters) no.3, creation rd. ii, science park, hsinchu, taiwan tel: 886-3-563-1999 fax: 886-3-563-1189 http://www.holtek.com.tw holtek semiconductor inc. (taipei sales office) 4f-2, no. 3-2, yuanqu st., nankang software park, taipei 115, taiwan tel: 886-2-2655-7070 fax: 886-2-2655-7373 fax: 886-2-2655-7383 (international sales hotline) holtek semiconductor inc. (shenzhen sales office) 5f, unit a, productivity building, no.5 gaoxin m 2nd road, nanshan district, shenzhen, china 518057 tel: 86-755-8616-9908, 86-755-8616-9308 fax: 86-755-8616-9722 holtek semiconductor (usa), inc. (north america sales office) 46729 fremont blvd., fremont, ca 94538, usa tel: 1-510-252-9880 fax: 1-510-252-9885 http://www.holtek.com


▲Up To Search▲   

 
Price & Availability of HT82A520R11

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X